1 | <?php declare(strict_types=1); |
||
8 | class DefinitionAggregate implements DefinitionAggregateInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var Definition[] |
||
12 | */ |
||
13 | protected $definitions = []; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $references = []; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $aliases = []; |
||
24 | |||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $analyzeReferences = true; |
||
29 | |||
30 | /** |
||
31 | * Set analyze all added classes with class_parents and class_implements and create references. |
||
32 | * When you add Child class to container and try get object by Parent class you will get Child class object |
||
33 | * that described in container. |
||
34 | * |
||
35 | * @param bool $analyzeReferences |
||
36 | */ |
||
37 | 1 | public function setAnalyzeReferences(bool $analyzeReferences): void |
|
41 | |||
42 | /** |
||
43 | * {@inheritDoc} |
||
44 | */ |
||
45 | 22 | public function addDefinition(string $name, DefinitionInterface $definition): DefinitionInterface |
|
57 | |||
58 | /** |
||
59 | * Add references by class parents and interfaces |
||
60 | * |
||
61 | * @param string $name |
||
62 | * @param string $class |
||
63 | */ |
||
64 | 21 | protected function addReferences(string $name, string $class): void |
|
76 | |||
77 | /** |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | 21 | public function addReference(string $name, string $class): void |
|
87 | |||
88 | |||
89 | 22 | public function addAliases(string $name, array $aliases = []): void |
|
95 | |||
96 | 5 | public function addAlias(string $name, string $alias): void |
|
103 | |||
104 | /** |
||
105 | * {@inheritDoc} |
||
106 | */ |
||
107 | 11 | public function get(string $id): DefinitionInterface |
|
115 | |||
116 | /** |
||
117 | * {@inheritDoc} |
||
118 | */ |
||
119 | 22 | public function has(string $id): bool |
|
127 | |||
128 | /** |
||
129 | * Find definition name by aliases, references, etc |
||
130 | * |
||
131 | * @param string $id |
||
132 | * @return string |
||
133 | * @throws NotFoundException |
||
134 | */ |
||
135 | 11 | public function resolveDefinitionName(string $id): string |
|
143 | |||
144 | /** |
||
145 | * @param $id |
||
146 | * @return string|null |
||
147 | */ |
||
148 | 14 | protected function findDefinitionName($id): ?string |
|
163 | } |
||
164 |