1 | <?php |
||
21 | class Supervisor implements SupervisorInterface |
||
22 | { |
||
23 | /** |
||
24 | * Used to create unique node names when required. |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | private static $index = 0; |
||
29 | |||
30 | /** |
||
31 | * Active set of imports. |
||
32 | * |
||
33 | * @var ImporterInterface[] |
||
34 | */ |
||
35 | private $importers = []; |
||
36 | |||
37 | /** |
||
38 | * @var SyntaxInterface |
||
39 | */ |
||
40 | protected $syntax = null; |
||
41 | |||
42 | /** |
||
43 | * @var LoaderInterface |
||
44 | */ |
||
45 | protected $loader = null; |
||
46 | |||
47 | /** |
||
48 | * @param LoaderInterface $loader |
||
49 | * @param SyntaxInterface $syntax |
||
50 | */ |
||
51 | public function __construct(LoaderInterface $loader, SyntaxInterface $syntax) |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function getSyntax(): SyntaxInterface |
||
61 | { |
||
62 | return $this->syntax; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Add new elements import locator. |
||
67 | * |
||
68 | * @param ImporterInterface $import |
||
69 | */ |
||
70 | public function registerImporter(ImporterInterface $import) |
||
74 | |||
75 | /** |
||
76 | * Active templater imports. |
||
77 | * |
||
78 | * @return ImporterInterface[] |
||
79 | */ |
||
80 | public function getImporters() |
||
84 | |||
85 | /** |
||
86 | * Remove all element importers. |
||
87 | */ |
||
88 | public function flushImporters() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function tokenBehaviour(array $token, array $content, Node $node) |
||
142 | |||
143 | /** |
||
144 | * Create node based on given location with identical supervisor (cloned). |
||
145 | * |
||
146 | * @param string $path |
||
147 | * @param array $token Context token. |
||
148 | * |
||
149 | * @return Node |
||
150 | * @throws StemplerException |
||
151 | */ |
||
152 | public function createNode(string $path, array $token = []): Node |
||
173 | |||
174 | /** |
||
175 | * Get unique placeholder name, unique names are required in some cases to correctly process |
||
176 | * includes and etc. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function uniquePlaceholder(): string |
||
184 | |||
185 | /** |
||
186 | * Clarify exeption with it's actual location. |
||
187 | * |
||
188 | * @param StemplerSource $sourceContext |
||
189 | * @param StemplerException $exception |
||
190 | * |
||
191 | * @return StemplerException |
||
192 | */ |
||
193 | protected function clarifyException( |
||
222 | } |