Пример #1
0
 public function exec()
 {
     $this->getControllerClass()->run();
     // eseguo il controller
     // butto fuori il contenuto
     echo $this->getControllerClass()->getContent();
     return;
     try {
         Events::trigger(self::CONTROLLER_CLASS_INSTANCE);
     } catch (ControllerException $ex) {
         if ($ex->getCode() == Controller::CONTROLLER_NOT_FOUND) {
             $this->getControllerClass()->errorControllerNotFound();
             // invia un 404
         }
         if ($ex->getCode() == Controller::ACTION_NOT_FOUND) {
             $this->getControllerClass()->errorActionNotFound();
         }
     }
     try {
         $this->getResponseClass()->sendHeader();
         $this->getViewClass()->outputContent();
     } catch (ViewException $ex) {
         if ($ex->getCode() == View::TEMPLATE_NOT_FOUND) {
             $this->getControllerClass()->errorTemplateNotFound();
             $this->getViewClass()->outputContent();
             // qua deve funzionare per forza
         }
     }
 }
Пример #2
0
 /**
  * Invia tutti gli header pre-impostati
  */
 public function sendHeader()
 {
     Events::trigger(self::RESPONSE_SEND_HEADERS, array($this));
     $httpCode = $this->getHttpCode();
     $protocol = $this->getRequestClass()->getHttpProtocol();
     $message = $this->_messageCode[$httpCode];
     $headerResponse = $protocol . ' ' . $httpCode . ' ' . $message;
     header($headerResponse, true, $httpCode);
     // invio l'http code
     foreach ($this->_headers as $headerName => $headerValue) {
         // invio tutti gli header
         header($headerName . ': ' . $headerValue, true);
     }
     // il cnotroller dirà alla vista di inviare il contenuto
 }