Ejemplo n.º 1
0
 /**
  * Handle events before a dispatch exception occurs
  * 
  * @param  Event         $event     
  * @param  MVCDispatcher $dispatcher
  * @param  Exception     $exception 
  * @return bool                   
  */
 public function beforeException(Event $event, MVCDispatcher $dispatcher, Exception $exception)
 {
     switch ($exception->getCode()) {
         case PhalconDispatcher::EXCEPTION_HANDLER_NOT_FOUND:
         case PhalconDispatcher::EXCEPTION_ACTION_NOT_FOUND:
             return $this->handleNotFound($dispatcher, $exception);
     }
 }
 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param MvcDispatcher $dispatcher
  * @param Exception $exception
  * @return boolean
  */
 public function beforeException(Event $event, MvcDispatcher $dispatcher, DispatcherException $exception)
 {
     error_log($exception->getMessage() . PHP_EOL . $exception->getTraceAsString());
     if ($exception instanceof DispatcherException) {
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                 $dispatcher->forward(array('controller' => 'error', 'action' => 'error404'));
                 return false;
         }
     }
     $dispatcher->forward(array('controller' => 'errors', 'action' => 'show500'));
     return false;
 }