1
|
|
|
<?php |
2
|
|
|
namespace PSB\Core\Pipeline; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use PSB\Core\ObjectBuilder\BuilderInterface; |
6
|
|
|
|
7
|
|
|
class PipelineModifications |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var StepRegistration[] |
11
|
|
|
*/ |
12
|
|
|
private $additions = []; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var StepRemoval[] |
16
|
|
|
*/ |
17
|
|
|
private $removals = []; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var StepReplacement[] |
21
|
|
|
*/ |
22
|
|
|
private $replacements = []; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param string $stepId |
26
|
|
|
* |
27
|
|
|
* @return StepRemoval |
28
|
|
|
*/ |
29
|
1 |
|
public function removeStep($stepId) |
30
|
|
|
{ |
31
|
1 |
|
$removal = new StepRemoval($stepId); |
32
|
1 |
|
$this->removals[] = $removal; |
33
|
1 |
|
return $removal; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $stepId |
38
|
|
|
* @param string $stepFqcn |
39
|
|
|
* @param callable|null $factory |
40
|
|
|
* @param string|null $description |
41
|
|
|
* |
42
|
|
|
* @return StepReplacement |
43
|
|
|
*/ |
44
|
2 |
|
public function replaceStep($stepId, $stepFqcn, callable $factory = null, $description = null) |
45
|
|
|
{ |
46
|
2 |
|
$replacement = new StepReplacement($stepId, $stepFqcn, $factory, $description); |
47
|
2 |
|
$this->replacements[] = $replacement; |
48
|
2 |
|
return $replacement; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $stepId |
53
|
|
|
* @param string $stepFqcn |
54
|
|
|
* @param callable|null $factory |
55
|
|
|
* @param string|null $description |
56
|
|
|
* |
57
|
|
|
* @return StepRegistration |
58
|
|
|
*/ |
59
|
2 |
|
public function registerStep($stepId, $stepFqcn, callable $factory = null, $description = null) |
60
|
|
|
{ |
61
|
2 |
|
$registration = new StepRegistration($stepId, $stepFqcn, $factory, $description); |
62
|
2 |
|
$this->additions[] = $registration; |
63
|
2 |
|
return $registration; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param BuilderInterface $builder |
68
|
|
|
*/ |
69
|
1 |
|
public function registerStepsInBuilder(BuilderInterface $builder) |
70
|
|
|
{ |
71
|
1 |
|
foreach ($this->replacements as $replacement) { |
72
|
1 |
|
$replacement->registerInBuilder($builder); |
73
|
|
|
} |
74
|
|
|
|
75
|
1 |
|
foreach ($this->additions as $registration) { |
76
|
1 |
|
$registration->registerInBuilder($builder); |
77
|
|
|
} |
78
|
1 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return StepRegistration[] |
82
|
|
|
*/ |
83
|
1 |
|
public function getAdditions() |
84
|
|
|
{ |
85
|
1 |
|
return $this->additions; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return StepRemoval[] |
90
|
|
|
*/ |
91
|
1 |
|
public function getRemovals() |
92
|
|
|
{ |
93
|
1 |
|
return $this->removals; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return StepReplacement[] |
98
|
|
|
*/ |
99
|
1 |
|
public function getReplacements() |
100
|
|
|
{ |
101
|
1 |
|
return $this->replacements; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|