Pipeline.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Di\Aop;
  12. use Closure;
  13. use Hyperf\Di\Exception\InvalidDefinitionException;
  14. class Pipeline extends \Hyperf\Pipeline\Pipeline
  15. {
  16. protected function carry(): Closure
  17. {
  18. return function ($stack, $pipe) {
  19. return function ($passable) use ($stack, $pipe) {
  20. if (is_string($pipe) && class_exists($pipe)) {
  21. $pipe = $this->container->get($pipe);
  22. }
  23. if (! $passable instanceof ProceedingJoinPoint) {
  24. throw new InvalidDefinitionException('$passable must is a ProceedingJoinPoint object.');
  25. }
  26. $passable->pipe = $stack;
  27. return method_exists($pipe, $this->method) ? $pipe->{$this->method}($passable) : $pipe($passable);
  28. };
  29. };
  30. }
  31. }