A new concept called "pipelines" is introduced. It follows the concept
of having a "payload" (data), wrapped in an "envelope", coming from an object
(the "subject"), which goes down a "pipeline" where the data could
be modified by any third party callables ("pipes").
This is the construct:
-- Pipes --
Are simply callables, and are registered via a file within
EXT:myext/Configuration/Pipelines.php. It is done very early at a bootstrap.
An extension can register multiple pipes for various pipelines. The format is as
follows:
return [
'benni/pipe-example/mypipe' => [
'pipeline' => 'persistence.datahandler.addrecord',
'target' => 'Benni\\PipeExample\\Pipeline\\MyPipe->callMe',
'description' => 'Helpful for others what this pipe is doing',
'before' => ['some-other-pipe', 'and-the-realurl-pipe'],
'after' => ['the-gridelements-pipe']
];
Some facts on that:
- Only "pipeline" and "target" are mandatory.
- "pipeline" is the identifier of the pipeline which could be called by TYPO3
- "target" is your callable code
- "before/after" is used for dependency resolving to ensure your stuff is run before/after a certain other pipe WITHIN that pipeline.
-- Envelopes --
The pipe class/method will receive an "Envelope" holding the subject (e.g. datahandler), and the payload (data to be modified) which is an ArrayAccess
object. The payload can thus be modified, the pipe does not have to return
anything at all.
-- Pipeline --
Is not explicitly visible currently (it is possible to add a pipeline which could
stop if a certain exception or option is thrown/set), but it's the chain handing
the envelope to all registered pipes.
- The PipelineManager (Singleton) --
The pipeline manager is the entrypoint within the bootstrap to aggregate and sort
the pipes, and also having a pipe('my.pipe.name', $subject, $payload) method
to call a pipeline, and always returns the payload again.
Basic concept:
- It's there for data manipulation
- Pipes have an order within a pipeline
- Pipes cannot be modified/added/removed during regular runtime
- Pipes can replace other pipes (by using the same pipe identifier)
- Pipes are always bound to a specific pipeline
- PipelineManager is the place where all pipes are kept, and is fully cached
after dependency ordering was taken place