示例#1
0
 public function getRouteName()
 {
     if (!$this->_routeName) {
         $this->_routeName = \Kalibri::router()->getController() . '_' . \Kalibri::router()->getAction();
     }
     return $this->_routeName;
 }
示例#2
0
文件: Page.php 项目: tenebras/kalibri
 /**
  * Find view for current controller
  *
  * @param string $directory
  * @param string $controller
  * @param string $action
  *
  * @throws \Kalibri\Exception\View\NotFound
  *
  * @return string
  */
 public function findView($directory = null, $controller = null, $action = null)
 {
     $directory = $directory ?: \Kalibri::router()->getDirectory();
     $controller = $controller ?: \Kalibri::router()->getController();
     $action = $action ?: \Kalibri::router()->getAction();
     //Is directory set to find in
     if (\strcmp($directory, '') != 0) {
         if ($this->getView()->isExists("{$directory}/{$controller}/{$action}", $this->_alternativeViewLocation)) {
             return "{$directory}/{$controller}/{$action}";
         } elseif ($this->getView()->isExists("{$directory}/{$controller}", $this->_alternativeViewLocation)) {
             return "{$directory}/{$controller}";
         } elseif ($this->getView()->isExists("{$directory}/{$controller}_{$action}", $this->_alternativeViewLocation)) {
             return "{$directory}/{$controller}_{$action}";
         }
     }
     //Controller and method
     if ($this->getView()->isExists("{$controller}/{$action}", $this->_alternativeViewLocation)) {
         return "{$controller}/{$action}";
     }
     //Controller and method
     if ($this->getView()->isExists("{$controller}_{$action}", $this->_alternativeViewLocation)) {
         return "{$controller}_{$action}";
     }
     //Controller
     if ($this->getView()->isExists($controller, $this->_alternativeViewLocation)) {
         return $controller;
     }
     throw new \Kalibri\Exception\View\NotFound("Can't automaticaly find view file " . "for controller: '{$controller}' method: '{$action}' directory: '{$directory}'");
 }
示例#3
0
 protected function init()
 {
     K_COMPILE_ROUTES && \Kalibri::compiler()->compile(Compiler::NAME_BASE);
     \Kalibri::config()->load();
     if ($this->_mode) {
         try {
             \Kalibri::config()->load($this->_mode);
         } catch (\Exception $e) {
         }
     }
     // Set list of classes that will be auto inited on use
     \Kalibri::setAutoInitClasses(\Kalibri::config()->get('init.classes'));
     //\Kalibri::logger()->init( \Kalibri::config()->get('debug.log') );
     \Kalibri::router()->setSegments(\Kalibri::uri()->getSegments());
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (\Kalibri::config()->get('debug.log.is-enabled', false)) {
         \Kalibri::logger()->add(\Kalibri\Logger\Base::L_DEBUG, 'init', $this);
     }
     ob_start();
 }