示例#1
0
 /**
  * Instantiate Whoops with the correct handlers.
  */
 public function init()
 {
     parent::init();
     require 'YiiWhoopsRunner.php';
     $this->whoops = new YiiWhoopsRunner();
     if (Yii::app()->request->isAjaxRequest) {
         $this->whoops->pushHandler(new JsonResponseHandler());
     } else {
         $page_handler = new PrettyPageHandler();
         if (isset($this->pageTitle)) {
             $page_handler->setPageTitle($this->pageTitle);
         }
         if (isset($this->editor)) {
             $editor = $this->editor;
             switch ($editor) {
                 case 'sublime':
                 case 'emacs':
                 case 'textmate':
                 case 'macvim':
                 case 'xdebug':
                     $page_handler->setEditor($editor);
                     break;
                 default:
                     $page_handler->setEditor(function ($file, $line) use($editor) {
                         return strtr($editor, array('{file}' => $file, '{line}' => $line));
                     });
                     break;
             }
         }
         $this->whoops->pushHandler($page_handler);
     }
 }
示例#2
0
 public function init()
 {
     parent::init();
     // deal with fatal error such as E_PARSE, E_CORE_ERROR
     if (!YII_DEBUG) {
         register_shutdown_function(array($this, 'onErrorShutdown'));
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (is_null($this->ignoreException)) {
         $this->ignoreException = function ($exception) {
             /** @var \CHttpException $exception */
             return $exception instanceof \CHttpException && $exception->statusCode == 404;
         };
     }
 }
示例#4
0
 /**
  *
  */
 public function init()
 {
     parent::init();
     $admin = false;
     if (!craft()->isConsole() && Craft::isInstalled()) {
         // Set whether the currently logged in user is an admin.
         if (isset(craft()->userSession)) {
             if (($currentUser = craft()->userSession->getUser()) !== null) {
                 $admin = $currentUser->admin == 1 ? true : false;
             }
         }
     }
     $this->_devMode = craft()->config->get('devMode') || $admin;
 }
 /**
  * Init the error handler, register a shutdown function to catch fatal errors and track the request.
  * @return mixed
  */
 public function init()
 {
     // init the audit module
     Yii::app()->getModule('audit');
     // catch fatal errors
     if ($this->catchFatalErrors) {
         //Yii::app()->onEndRequest[] = array($this, 'handleFatalError');
         register_shutdown_function(array($this, 'handleFatalError'));
         ob_start(array($this, 'handleFatalBuffer'));
     }
     // track the request
     if ($this->trackAllRequests) {
         $this->getAuditRequest();
     }
     // call parent
     parent::init();
 }
示例#6
0
 /**
  * Initializes the error handler.
  */
 public function init()
 {
     parent::init();
     Yii::app()->attachEventHandler('onEndRequest', array($this, 'onShutdown'));
 }