Skip to content

Commit

Permalink
[5.2] Allow objects to be passed as pipes
Browse files Browse the repository at this point in the history
Allows following code to be executed, very useful in case pipes require some complex constructing or already exist.
```php
(new Pipeline($app))->send($subject)->through([new A, new B])->via('pipe_method')->then(...);
```
  • Loading branch information
Roman Kinyakin committed Apr 5, 2016
1 parent 8495627 commit 1aafae2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Illuminate/Pipeline/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@ protected function getSlice()
// the appropriate method and arguments, returning the results back out.
if ($pipe instanceof Closure) {
return call_user_func($pipe, $passable, $stack);
} else {
} elseif (! is_object($pipe)) {
list($name, $parameters) = $this->parsePipeString($pipe);

return call_user_func_array([$this->container->make($name), $this->method],
array_merge([$passable, $stack], $parameters));
$pipe = $this->container->make($name);
$parameters = array_merge([$passable, $stack], $parameters);
} else {
$parameters = [$passable, $stack];
}

return call_user_func_array([$pipe, $this->method], $parameters);
};
};
}
Expand Down

0 comments on commit 1aafae2

Please sign in to comment.