File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -118,13 +118,30 @@ public function addPath(string $path) : void
118118 * @param string $cachePath Путь к кэшу (серверный).
119119 *
120120 * @return Environment
121+ * @throws LoaderError Ошибки Твига.
121122 */
122123 private function initTwig (
123124 FilesystemLoader $ loader ,
124125 string $ debug ,
125126 string $ cachePath
126127 ) : Environment {
127128
129+ $ allPaths = $ loader ->getPaths ();
130+
131+ if (array_key_exists ('paths ' , $ this ->twigOptions )) {
132+ foreach ($ this ->twigOptions ['paths ' ] as $ path => $ namespace ) {
133+ if (in_array (trim ($ path ), $ allPaths , true )) {
134+ continue ;
135+ }
136+
137+ if (!$ namespace ) {
138+ $ loader ->addPath ($ path );
139+ } else {
140+ $ loader ->addPath ($ path , $ namespace );
141+ }
142+ }
143+ }
144+
128145 return new Environment (
129146 $ loader ,
130147 [
You can’t perform that action at this time.
0 commit comments