コード例 #1
0
ファイル: Manager.php プロジェクト: panlatent/swilab
 /**
  * @return \Swilab\Exception\Manager
  */
 public static function getDefault()
 {
     if (static::$instance) {
         return static::$instance;
     }
     static::$instance = new self();
     static::$instance->setDI(Swilab::getDI());
     return static::$instance;
 }
コード例 #2
0
ファイル: Exception.php プロジェクト: panlatent/swilab
 public function __construct($message = '', $code = 0, \Exception $previous = null, $level = self::WARNING, $automaticLog = null, $logName = null)
 {
     parent::__construct($message, $code, $previous);
     $this->level = $level;
     $this->logName = $logName ?: static::$defaultLogName;
     false !== $automaticLog && static::$automaticLog and ExceptionManager::getDefault()->addException($this);
 }
コード例 #3
0
ファイル: Application.php プロジェクト: panlatent/swilab
 public function handle($uri = null)
 {
     $this->router->handle();
     $this->dispatcher->setNamespaceName($this->router->getNamespaceName());
     $this->dispatcher->setControllerName($this->router->getControllerName());
     $this->dispatcher->setActionName($this->router->getActionName());
     $this->dispatcher->setParams($this->router->getParams());
     $this->view->start();
     try {
         $this->dispatcher->dispatch();
     } catch (\Exception $exception) {
         if (!$exception instanceof Exception) {
             ExceptionManager::getDefault()->addException($exception);
         }
         switch ($exception->getCode()) {
             case Dispatcher::EXCEPTION_FORBIDDEN:
                 $this->{$dispatcher}->forward($this->router->getForbidden());
                 break;
             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
             case Dispatcher::EXCEPTION_NOT_FOUND:
                 $this->{$dispatcher}->forward($this->router->getNotFound());
                 break;
             case Dispatcher::EXCEPTION_SERVER_ERROR:
             default:
                 $this->dispatcher->forward($this->router->getServerError());
         }
         $this->dispatcher->dispatch();
     }
     $possibleResponse = $this->dispatcher->getReturnedValue();
     $returnedResponse = $possibleResponse instanceof ResponseInterface;
     if (!$returnedResponse) {
         $this->view->render($this->dispatcher->getControllerName(), $this->dispatcher->getActionName(), $this->dispatcher->getParams());
     }
     $this->view->finish();
     if (!$returnedResponse) {
         $this->response->setContent($this->view->getContent());
     }
     $this->response->sendHeaders();
     $this->response->sendCookies();
     if ($this->config->get('app.log.enable', false)) {
         ExceptionManager::getDefault()->handle();
     }
     return $this->response;
 }
コード例 #4
0
ファイル: FactoryDefault.php プロジェクト: panlatent/swilab
 protected function registerException()
 {
     return ExceptionManager::getDefault();
 }