[5.7] Add thenReturn method to Pipeline #27429
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Often when using a pipeline there is additional work to be done to the object passed through. A good example of this is using the Pipeline to apply additional filters to a query builder, perhaps based off a request's query parameters. Current you could do the following...
or...
or...
or you could merge in a closure based pipe, and so on.
Adding a helper method to return the
$passable
allows for continued chaining in the same scope, so the above examples become...which I personally think feels nice when simple running the pipeline does not complete the preparation/manipulation of the
$passable
.There are also scenarios where you just wanna run something through a pipeline and you don't need to do any additional work to it...
Although I have named the method
thenReturn
, it may not be the best name for this. I thoughtrun
might also be an option, as you are running the passable through the pipeline.