protected function findTemplate($name)
 {
     $throw = func_num_args() > 1 ? func_get_arg(1) : true;
     $name = $this->normalizeName($name);
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (isset($this->errorCache[$name])) {
         if (!$throw) {
             return false;
         }
         throw new \Twig_Error_Loader($this->errorCache[$name]);
     }
     $this->validateName($name);
     list($module, $shortname) = $this->parseName($name);
     if (null == $module) {
         // currentSegment
         $viewPath = $this->currentSegment->resolvePath('views/' . $shortname);
     } elseif (true === $module) {
         // Root
         $viewPath = $this->application->resolvePath('views/' . $shortname);
     } else {
         // Module
         $viewPath = $this->application->getModuleManager()->getModule($module)->resolvePath('views/' . $shortname);
     }
     if (is_file($viewPath)) {
         return $this->cache[$name] = $viewPath;
     }
     $this->errorCache[$name] = sprintf('Unable to find template "%s"  (File does not exist: %s).', $name, $viewPath);
     if (!$throw) {
         return false;
     }
     throw new \Twig_Error_Loader($this->errorCache[$name]);
 }
Пример #2
0
 public function __construct(string $moduleName, ModuleAdapter $adapter, Application $application, Config $config)
 {
     parent::__construct($config, new DI());
     $this->application = $application;
     $this->name = $moduleName;
     $this->adapter = $adapter;
     $adapter->initializeWith($this);
 }
 public function __construct(string $directory, ClassLoader $classLoader, array $options = [])
 {
     $di = new DirectoryDi($directory . '/services', [$this]);
     parent::__construct($directory, $di);
     $this->dev = (bool) ($options['dev'] ?? false);
     $this->classLoader = $classLoader;
     if ($this->isDev()) {
         $this->registerErrorHandler();
     }
     call_user_func(require $this->resolvePath('application.php'), $this);
 }
 public function __construct(string $moduleName, string $directory, Application $application, DI $di)
 {
     parent::__construct($directory, $di);
     $this->application = $application;
     $this->name = $moduleName;
 }
Пример #5
0
 public function __construct(Config $config, ClassLoader $classLoader, DI $di, $devMode = false)
 {
     parent::__construct($config, $di);
     $this->dev = $devMode;
     $this->classLoader = $classLoader;
 }