1 | <?php |
||
49 | class Configurator implements ConfigProvider |
||
50 | { |
||
51 | /** |
||
52 | * @var AttributeFilterCollection Dynamically-populated collection of AttributeFilter instances |
||
53 | */ |
||
54 | public $attributeFilters; |
||
55 | |||
56 | /** |
||
57 | * @var BundleGenerator Default bundle generator |
||
58 | */ |
||
59 | public $bundleGenerator; |
||
60 | |||
61 | /** |
||
62 | * @var JavaScript JavaScript manipulation object |
||
63 | */ |
||
64 | public $javascript; |
||
65 | |||
66 | /** |
||
67 | * @var PluginCollection Loaded plugins |
||
68 | */ |
||
69 | public $plugins; |
||
70 | |||
71 | /** |
||
72 | * @var array Array of variables that are available to the filters during parsing |
||
73 | */ |
||
74 | public $registeredVars; |
||
75 | |||
76 | /** |
||
77 | * @var Rendering Rendering configuration |
||
78 | */ |
||
79 | public $rendering; |
||
80 | |||
81 | /** |
||
82 | * @var Ruleset Rules that apply at the root of the text |
||
83 | */ |
||
84 | public $rootRules; |
||
85 | |||
86 | /** |
||
87 | * @var RulesGenerator Generator used by $this->getRenderer() |
||
88 | */ |
||
89 | public $rulesGenerator; |
||
90 | |||
91 | /** |
||
92 | * @var TagCollection Tags repository |
||
93 | */ |
||
94 | public $tags; |
||
95 | |||
96 | /** |
||
97 | * @var TemplateChecker Default template checker |
||
98 | */ |
||
99 | public $templateChecker; |
||
100 | |||
101 | /** |
||
102 | * @var TemplateNormalizer Default template normalizer |
||
103 | */ |
||
104 | public $templateNormalizer; |
||
105 | |||
106 | /** |
||
107 | * Constructor |
||
108 | * |
||
109 | * Prepares the collections that hold tags and filters, the UrlConfig object as well as the |
||
110 | * various helpers required to generate a full config. |
||
111 | */ |
||
112 | 45 | public function __construct() |
|
125 | |||
126 | //========================================================================== |
||
127 | // Magic methods |
||
128 | //========================================================================== |
||
129 | |||
130 | /** |
||
131 | * Magic __get automatically loads plugins, returns registered vars |
||
132 | * |
||
133 | * @param string $k Property name |
||
134 | * @return mixed |
||
135 | */ |
||
136 | 6 | public function __get($k) |
|
152 | |||
153 | /** |
||
154 | * Magic __isset checks existence in the plugins collection and registered vars |
||
155 | * |
||
156 | * @param string $k Property name |
||
157 | * @return bool |
||
158 | */ |
||
159 | 5 | public function __isset($k) |
|
168 | |||
169 | /** |
||
170 | * Magic __set adds to the plugins collection, registers vars |
||
171 | * |
||
172 | * @param string $k Property name |
||
173 | * @param mixed $v Property value |
||
174 | * @return mixed |
||
175 | */ |
||
176 | 2 | public function __set($k, $v) |
|
187 | |||
188 | /** |
||
189 | * Magic __set removes plugins from the plugins collection, unregisters vars |
||
190 | * |
||
191 | * @param string $k Property name |
||
192 | * @return mixed |
||
193 | */ |
||
194 | 2 | public function __unset($k) |
|
205 | |||
206 | //========================================================================== |
||
207 | // API |
||
208 | //========================================================================== |
||
209 | |||
210 | /** |
||
211 | * Enable the creation of a JavaScript parser |
||
212 | * |
||
213 | * @return void |
||
214 | */ |
||
215 | 3 | public function enableJavaScript() |
|
222 | |||
223 | /** |
||
224 | * Finalize this configuration and return all the relevant objects |
||
225 | * |
||
226 | * @return array One "parser" element and one "renderer" element unless specified otherwise |
||
227 | */ |
||
228 | 11 | public function finalize() |
|
263 | |||
264 | /** |
||
265 | * Load a bundle into this configuration |
||
266 | * |
||
267 | * @param string $bundleName Name of the bundle |
||
268 | * @return void |
||
269 | */ |
||
270 | 2 | public function loadBundle($bundleName) |
|
282 | |||
283 | /** |
||
284 | * Create and save a bundle based on this configuration |
||
285 | * |
||
286 | * @param string $className Name of the bundle class |
||
287 | * @param string $filepath Path where to save the bundle file |
||
288 | * @param array $options Options passed to the bundle generator |
||
289 | * @return bool Whether the write succeeded |
||
290 | */ |
||
291 | 3 | public function saveBundle($className, $filepath, array $options = []) |
|
297 | |||
298 | /** |
||
299 | * Generate and return the complete config array |
||
300 | * |
||
301 | * @return array |
||
302 | */ |
||
303 | 20 | public function asConfig() |
|
351 | |||
352 | /** |
||
353 | * Add the rules generated by $this->rulesGenerator |
||
354 | * |
||
355 | * @return void |
||
356 | */ |
||
357 | 11 | protected function addTagRules() |
|
371 | } |