Пример #1
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @return null|object
  */
 public function getLayoutAssign()
 {
     if ($this->_instance instanceof controller and isset($this->_instance->getView()->layout)) {
         /** Return */
         return (object) $this->_instance->getView()->layout;
     }
     /** Return */
     return null;
 }
Пример #2
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @throws \Exception
  */
 public function dispatch()
 {
     foreach ($this->_instance->getAssigns() as $name => $value) {
         $this->{$name} = $value;
     }
     if ($this->_instance->getHeaders()) {
         /** @var header $header */
         foreach ($this->_instance->getHeaders() as $header) {
             header($header->name . ': ' . $header->values);
         }
     }
     /** different view */
     if ($this->_instance->render() !== $this->_action) {
         $this->view = $this->_instance->render();
     }
     if (False === $this->view) {
         $_view_name = $this->_action . '.phtml';
     } else {
         $_view_name = $this->view . '.phtml';
     }
     /** @var string $_view */
     $_view = APPLICATION_PATH . '/application/module/' . $this->_module . '/view/' . $this->_controller . '/' . $_view_name;
     if (file_exists($_view)) {
         if (null !== $this->_external_library) {
             foreach ($this->_external_library as $library) {
                 echo $library . PHP_EOL;
             }
         }
         /** @noinspection PhpIncludeInspection */
         require_once $_view;
     } else {
         throw new \Exception('View ' . $this->_action . ' not found.');
     }
 }