예제 #1
0
파일: Error.php 프로젝트: cipherpols/cze
 /**
  * Does handle exception logic, e.g. logging them, disabling view,
  * passing info to view etc. pp.
  *
  * @param Exception $exception
  */
 protected function _handleException(Exception $exception)
 {
     $logMessage = Application\Error::toString($exception);
     Application::getLog()->crit($logMessage);
     // Are we in cli mode?
     if ('cli' === strtolower(PHP_SAPI)) {
         $this->disableView();
         return;
     }
     // Is that a user readable exception?
     if ($exception instanceof Exception) {
         $this->view->message = $logMessage;
         return;
     }
 }
예제 #2
0
파일: Base.php 프로젝트: cipherpols/cze
 /**
  * Runs MVC Application
  * @return void
  * @throws \Exception
  */
 public function run()
 {
     if (self::isInCliCall()) {
         $this->runCli();
         return;
     }
     \Zend_Registry::set(Constants::CZE_APPLICATION, static::$instance);
     $this->init();
     static::getRouter();
     try {
         /* @var \Zend_Controller_Front $front */
         $front = static::getFrontController();
         if ($front) {
             if (isset($_SERVER['REQUEST_URI'])) {
                 if (preg_match('#^/api/#', $_SERVER['REQUEST_URI']) === 1) {
                     $this->routeToApi($front);
                 }
             }
             $front->dispatch();
         }
     } catch (\Exception $e) {
         Application::getLog()->crit(Error::toString($e));
         if (APPLICATION_ENV === Constants::ENV_DEVELOPMENT) {
             throw $e;
         }
     }
 }
예제 #3
0
파일: DbEntity.php 프로젝트: cipherpols/cze
 /**
  * Returns the current dataset
  * @return Dataset
  */
 public function getDataset()
 {
     if (null === $this->dataset) {
         $this->dataset = new Dataset($this->tableName, null, 'id', $this->needsCreatedAt, $this->needsUpdatedAt, (bool) Application::getConfig()->resources->multidb->slave->enabled);
         if (!empty($this->primaryKey)) {
             $this->dataset->setPrimaryKey($this->primaryKey);
         }
     }
     return $this->dataset;
 }
예제 #4
0
 /**
  * Logs a message
  * @param string $message
  */
 protected function logMessage($message)
 {
     Application::getLog()->info($message);
 }
예제 #5
0
파일: Error.php 프로젝트: cipherpols/cze
 /**
  * @throws Exception
  */
 public function shutdownHandler()
 {
     $error = error_get_last();
     if (isset($error)) {
         $errorMessage = sprintf("%s in %s (%d)", $error['message'], $error['file'], $error['line']);
         Application::getLog()->crit(sprintf('%s got: %s', __METHOD__, $errorMessage));
         if (class_exists(Exception::class)) {
             throw new Exception($this, $errorMessage);
         } else {
             throw new \Exception($errorMessage);
         }
     }
 }