/** * @return Twig_Loader_Filesystem */ private function getTwigFilesystemLoader() { $paths = []; if ($this->config->isEmpty('theme')) { $paths[] = $this->config->get('layouts.path'); } elseif ($this->config->get('theme') == 'default') { $paths[] = $this->config->get('layouts.path') . '/default'; } else { $paths[] = $this->config->get('layouts.path') . '/' . $this->config->get('theme'); $paths[] = $this->config->get('layouts.path') . '/default'; } $paths[] = __DIR__ . '/layouts'; // Fallback $loader = new Twig_Loader_Filesystem($paths); // namespaces $namespaces = ['plugin' => $this->config->get('plugins.path'), 'page' => $this->config->get('pages.path'), 'post' => $this->config->get('posts.path'), 'site' => $this->config->get('site.path'), 'widget' => __DIR__ . '/Twig/widgets']; foreach ($namespaces as $namespace => $path) { if (is_readable($path)) { $loader->addPath($path, $namespace); } } return $loader; }