Exemple #1
0
 public function beforeHandleRequest($event, $engine)
 {
     //echo '<h3>before handle</h3>';
     if ($this->wrongModule) {
         //echo "wrong module";
         $dispatcher = Service::get(Service::DISPATCHER);
         $dispatcher->forward(array('controller' => 'index', 'action' => 'error', 'params' => array('code' => 404, 'message' => 'page not found')));
     }
 }
Exemple #2
0
 private function checkPermission($name)
 {
     $moduleName = $this->router->getModuleName();
     if (trim($moduleName) == false) {
         return;
     }
     $permission = Permission\Manager::checkPermission($moduleName, $name);
     $className = $this->router->getNamespaceName();
     dump('module ' . $moduleName . ' in namespace ' . $className . ' wanna get  ' . $name);
     if (Service::isService($name) && Engine::getInstance()->isRegisteredModule($moduleName) && !$permission) {
         //dump ( 'doesn\'t have permission for ' . $name . ' ' . $moduleName . ' ' . ( int ) $permission );
         Engine::throwException($name, 300);
     }
     return true;
 }
Exemple #3
0
 protected function onPrepareThemeAssets()
 {
     $src = TH_BASE_DIR . $this->assets->getPathTheme('css/');
     $themeCss = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/css';
     $compare = fileList($themeCss);
     unlinkDifferent($src, $compare);
     $list = fileList($src);
     foreach ($list as $file) {
         $this->assets->requireCss($this->assets->getPathTheme('css/' . $file));
     }
     $src = TH_BASE_DIR . $this->assets->getPathTheme('js/');
     $themeJs = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/js';
     $compare = fileList($themeJs);
     unlinkDifferent($src, $compare);
     $list = fileList($src);
     foreach ($list as $file) {
         $this->assets->requireJs($this->assets->getPathTheme('js/' . $file));
     }
     $themeImg = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/img';
     $compare = fileList($themeImg);
     unlinkDifferent($src, $compare);
 }
Exemple #4
0
 protected function onRegisterView($view)
 {
     $view->setViewsDir($this->configDirs->core->modules . $this->baseDir . '/views/');
     $engines = $this->manifest->getTemplateEngines();
     if (!$engines) {
         return;
     }
     $registerEngines = array();
     foreach ($engines as $engine) {
         if (!isset($engine['extension'])) {
             continue;
         }
         if (!Service::isService($engine['engine'])) {
             $engine['engine'] = '\\Phalcon\\Mvc\\View\\Engine\\' . ucfirst($engine['engine']);
         }
         $registerEngines['.' . $engine['extension']] = $engine['engine'];
     }
     //dump($registerEngines);
     if (count($registerEngines) > 0) {
         $view->registerEngines($registerEngines);
     }
 }
Exemple #5
0
 public function getPathTheme($resource, $absolute = false)
 {
     return $this->getPath('themes/' . Service::get(Service::THEME_NAME), $absolute) . $resource;
 }