1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nip\Dispatcher\Resolver\Pipeline; |
4
|
|
|
|
5
|
|
|
use League\Pipeline\InterruptibleProcessor; |
6
|
|
|
use League\Pipeline\PipelineBuilder as AbstractBuilder; |
7
|
|
|
use League\Pipeline\PipelineInterface; |
8
|
|
|
use League\Pipeline\ProcessorInterface; |
9
|
|
|
use Nip\Dispatcher\Commands\Command; |
10
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\ActionCallStage; |
11
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\ClassInstanceStage; |
12
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\ClosureStage; |
13
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\ModuleControllerStage; |
14
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\RequestStage; |
15
|
|
|
use Nip\Dispatcher\Resolver\Pipeline\Stages\ResolverCacheStage; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class ActionBuilder |
19
|
|
|
* @package Nip\Dispatcher\Resolver\Pipeline |
20
|
|
|
*/ |
21
|
|
|
class ActionBuilder extends AbstractBuilder |
22
|
|
|
{ |
23
|
8 |
|
public function __construct() |
24
|
|
|
{ |
25
|
8 |
|
$this->add(new ClosureStage()); |
26
|
8 |
|
$this->add(new RequestStage()); |
27
|
8 |
|
$this->add(new ResolverCacheStage()); |
28
|
8 |
|
$this->add(new ModuleControllerStage()); |
29
|
8 |
|
$this->add(new ClassInstanceStage()); |
30
|
8 |
|
$this->add(new ActionCallStage()); |
31
|
8 |
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Build a new Pipeline object |
35
|
|
|
* |
36
|
|
|
* @param ProcessorInterface|null $processor |
37
|
|
|
* |
38
|
|
|
* @return PipelineInterface |
39
|
|
|
*/ |
40
|
8 |
|
public function build(ProcessorInterface $processor = null): PipelineInterface |
41
|
|
|
{ |
42
|
8 |
|
if ($processor == null) { |
43
|
8 |
|
$processor = new InterruptibleProcessor( |
44
|
|
|
function (Command $command) { |
45
|
5 |
|
return !$command->hasReturn(); |
46
|
8 |
|
} |
47
|
|
|
); |
48
|
|
|
} |
49
|
8 |
|
return parent::build($processor); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|