/** * Base init */ private function baseInit() { // Add Page Title and Page Name (and other Variables defined in Router) to global $globalVariables = $this->router->getCurrentRoute()->getData(); $view = $this->application->getView(); DataCollection::each($globalVariables, function ($key, $value) use($view) { $view->set($key, $value); }); $config = $this->application->getConfig(); $cache = $this->application->getCache(); $request = $this->request; if ($config->get('app.metaAndTitleFromFile', false)) { $metaFilePath = $config->get('app.metaFile'); $metaPath = $this->appPath . DS . ltrim($metaFilePath, "/"); if (is_readable($metaPath)) { $metaContent = (include $metaPath); $metas = isset($metaContent[$request->getPath()]) ? $metaContent[$request->getPath()] : ''; } else { trigger_error(htmlentities("{$config->get('app.mataFile')} file not found or is not readable"), E_USER_WARNING); } if (!empty($metas)) { if (isset($metas['pageTitle'])) { $view->set('pageTitle', $metas['pageTitle']); unset($metas['pageTitle']); } $view->set('metas', $metas); } } $view->set('domainName', $config->get('app.websiteUrl', '')); $view->set('domain', $config->get('app.domain', '')); if ($cache->exists('csrf-token')) { $view->set('csrfToken', $cache->get('csrf-token')); } elseif (isset($_SESSION['csrf-token'])) { $view->set('csrfToken', $_SESSION['csrf-token']); } }
/** * Get Controller namespace * * @return mixed */ public function getControllerNamespace() { return $this->application->getConfig()->get('router.controller.namespace', '\\app\\Controllers'); }