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'))); } }
public function __construct() { $ref = new \ReflectionClass($this); $this->path = str_replace(basename($ref->getFileName()), '', $ref->getFileName()); $this->namespace = $ref->getNamespaceName(); $this->baseDir = basename(str_replace(basename($ref->getFileName()), '', $ref->getFileName())); $this->dispatcher = Service::get(Service::DISPATCHER); $this->view = Service::get(Service::VIEW); $this->assets = Service::get(Service::ASSETS); $this->loader = Service::get(Service::LOADER); $this->configDirs = $this->loader->getConfigDirs('../'); $this->manifest = Manifest\Reader::load($this->path . 'Manifest.xml'); $this->onConstruct(); }
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); }
public function getPathTheme($resource, $absolute = false) { return $this->getPath('themes/' . Service::get(Service::THEME_NAME), $absolute) . $resource; }