Esempio n. 1
0
File: Route.php Progetto: fraym/core
 /**
  * Init annotation and extension routes
  */
 public function loadRoutes()
 {
     if ($this->core->isCLI() === false && $this->cache->isCachingActive() && $this->user->isAdmin() === false) {
         if (($routes = $this->cache->getDataCache('routes')) === false) {
             $this->initAnnotationRoutes();
             $this->cache->setDataCache('routes', $this->virutalRoutes);
         } else {
             $this->virutalRoutes = $routes;
         }
     } else {
         $this->initExtensionRoutes();
         $this->initAnnotationRoutes();
     }
 }
Esempio n. 2
0
 /**
  * Template helper function to include another template file.
  *
  * @param $file
  * @param array $vars
  * @param null $cacheKey
  * @param bool $showError
  * @return bool|mixed|string
  */
 public function includeTemplate($file, $vars = [], $cacheKey = null, $showError = true)
 {
     $filename = $this->getTemplateFilePath($file);
     if (is_file($filename)) {
         if (count($vars)) {
             foreach ($vars as $templateVarName => $val) {
                 $this->assign($templateVarName, $val);
             }
         } else {
             $this->templateVars = $this->lastTemplateVars;
         }
         $content = $this->cache->getDataCache($cacheKey);
         if ($content === false) {
             $content = $this->prepareTemplate(file_get_contents($filename));
             if ($cacheKey !== null) {
                 $this->cache->setDataCache($cacheKey, $content);
             }
         }
         return $content;
     }
     return $showError ? "Template: {$file} not found." : "";
 }