1 | <?php |
||
11 | class DefinitionAggregate implements DefinitionAggregateInterface |
||
12 | { |
||
13 | use ContainerAwareTrait; |
||
14 | |||
15 | /** |
||
16 | * @var DefinitionInterface[] |
||
17 | */ |
||
18 | protected $definitions = []; |
||
19 | |||
20 | 114 | public function __construct(array $definitions = []) |
|
26 | |||
27 | 48 | public function add(string $id, $definition): DefinitionInterface |
|
37 | |||
38 | 12 | public function addShared(string $id, $definition): DefinitionInterface |
|
43 | |||
44 | 45 | public function has(string $id): bool |
|
54 | |||
55 | 24 | public function hasTag(string $tag): bool |
|
65 | |||
66 | 30 | public function getDefinition(string $id): DefinitionInterface |
|
76 | |||
77 | 21 | public function resolve(string $id) |
|
81 | |||
82 | 3 | public function resolveNew(string $id) |
|
83 | { |
||
84 | 3 | return $this->getDefinition($id)->resolveNew(); |
|
85 | } |
||
86 | |||
87 | 9 | public function resolveTagged(string $tag): array |
|
99 | |||
100 | 3 | public function resolveTaggedNew(string $tag): array |
|
101 | { |
||
102 | 3 | $arrayOf = []; |
|
103 | |||
104 | 3 | foreach ($this->getIterator() as $definition) { |
|
105 | 3 | if ($definition->hasTag($tag)) { |
|
106 | 3 | $arrayOf[] = $definition->setContainer($this->getContainer())->resolveNew(); |
|
107 | } |
||
108 | } |
||
109 | |||
110 | 3 | return $arrayOf; |
|
111 | } |
||
112 | |||
113 | 57 | public function getIterator(): Generator |
|
117 | } |
||
118 |