1 | <?php |
||
19 | class ViewConfig extends AbstractConfig |
||
20 | { |
||
21 | /** |
||
22 | * @var array $paths |
||
23 | */ |
||
24 | private $paths = []; |
||
25 | |||
26 | /** |
||
27 | * @var array $engines |
||
28 | */ |
||
29 | private $engines = []; |
||
30 | |||
31 | /** |
||
32 | * @var string $defaultEngine |
||
33 | */ |
||
34 | private $defaultEngine; |
||
35 | |||
36 | /** |
||
37 | * @return array |
||
38 | */ |
||
39 | public function defaults(): array |
||
40 | { |
||
41 | return [ |
||
42 | 'paths' => [], |
||
43 | 'engines' => [ |
||
44 | 'mustache' => [ |
||
45 | 'cache' => MustacheEngine::DEFAULT_CACHE_PATH |
||
46 | ], |
||
47 | 'php' => [], |
||
48 | 'php-mustache' => [], |
||
49 | 'twig' => [ |
||
50 | 'cache' => TwigEngine::DEFAULT_CACHE_PATH |
||
51 | ] |
||
52 | ], |
||
53 | 'default_engine' => 'mustache' |
||
54 | ]; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param array $paths The paths to search into. |
||
59 | * @return self |
||
60 | */ |
||
61 | public function setPaths(array $paths) |
||
62 | { |
||
63 | $this->paths = []; |
||
64 | $this->addPaths($paths); |
||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param string[] $paths One or more search paths. |
||
70 | * @return self |
||
71 | */ |
||
72 | public function addPaths(array $paths) |
||
79 | |||
80 | /** |
||
81 | * @param string $path A path to add to the paths list. |
||
82 | * @throws InvalidArgumentException If the path is not a string. |
||
83 | * @return self |
||
84 | */ |
||
85 | public function addPath(string $path) |
||
90 | |||
91 | /** |
||
92 | * @return array |
||
93 | */ |
||
94 | public function paths(): array |
||
98 | |||
99 | /** |
||
100 | * @param array $engines The various engines configuration. |
||
101 | * @return self |
||
102 | */ |
||
103 | public function setEngines(array $engines) |
||
111 | |||
112 | /** |
||
113 | * @param string $engineIdent The engine identifier. |
||
114 | * @param array $engineConfig The engine configuration data. |
||
115 | * @return self |
||
116 | */ |
||
117 | public function addEngine(string $engineIdent, array $engineConfig) |
||
122 | |||
123 | /** |
||
124 | * @return array |
||
125 | */ |
||
126 | public function engines(): array |
||
130 | |||
131 | /** |
||
132 | * Get an engine's configuration. |
||
133 | * |
||
134 | * @param string|null $engineIdent The engine identifier to get the configuration of. |
||
135 | * @throws InvalidArgumentException If the engine ident does not match any engines. |
||
136 | * @return array |
||
137 | */ |
||
138 | public function engine(?string $engineIdent = null): array |
||
150 | |||
151 | /** |
||
152 | * @param string $engineIdent The default engine (identifier). |
||
153 | * @return self |
||
154 | */ |
||
155 | public function setDefaultEngine(string $engineIdent) |
||
160 | |||
161 | /** |
||
162 | * @return string |
||
163 | */ |
||
164 | public function defaultEngine(): string |
||
168 | } |
||
169 |