Exemplo n.º 1
0
 public function getBitrixController()
 {
     if (null === $this->_bitrix) {
         require_once 'BxZender/Controller/Bitrix.php';
         $this->_bitrix = BxZender_Controller_Bitrix::getInstance();
     }
     return $this->_bitrix;
 }
Exemplo n.º 2
0
 /**
  * Called before Zend_Controller_Front exits its dispatch loop.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function dispatchLoopShutdown()
 {
     foreach ($this->_plugins as $plugin) {
         try {
             $plugin->dispatchLoopShutdown();
         } catch (Exception $e) {
             if (BxZender_Controller_Bitrix::getInstance()->throwExceptions()) {
                 throw $e;
             } else {
                 $this->getResponse()->setException($e);
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Singleton instance
  *
  * @return Zend_Controller_Front
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemplo n.º 4
0
 /**
  * Handle errors and exceptions
  *
  * If the 'noErrorHandler' front controller flag has been set,
  * returns early.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 protected function _handleError(BxZender_Controller_Request_AbstractRequest $request)
 {
     $bitrix = BxZender_Controller_Bitrix::getInstance();
     if ($bitrix->getParam('noErrorHandler')) {
         return;
     }
     $response = $this->getResponse();
     if ($this->_isInsideErrorHandlerLoop) {
         $exceptions = $response->getException();
         if (count($exceptions) > $this->_exceptionCountAtFirstEncounter) {
             // Exception thrown by error handler; tell the front controller to throw it
             $bitrix->throwExceptions(true);
             throw array_pop($exceptions);
         }
     }
     // check for an exception AND allow the error handler controller the option to forward
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         $this->_isInsideErrorHandlerLoop = true;
         // Get exception information
         $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         $exceptions = $response->getException();
         $exception = $exceptions[0];
         $exceptionType = get_class($exception);
         $error->exception = $exception;
         switch ($exceptionType) {
             case 'Zend_Controller_Router_Exception':
                 if (404 == $exception->getCode()) {
                     $error->type = self::EXCEPTION_NO_ROUTE;
                 } else {
                     $error->type = self::EXCEPTION_OTHER;
                 }
                 break;
             case 'Zend_Controller_Dispatcher_Exception':
                 $error->type = self::EXCEPTION_NO_CONTROLLER;
                 break;
             case 'Zend_Controller_Action_Exception':
                 if (404 == $exception->getCode()) {
                     $error->type = self::EXCEPTION_NO_ACTION;
                 } else {
                     $error->type = self::EXCEPTION_OTHER;
                 }
                 break;
             default:
                 $error->type = self::EXCEPTION_OTHER;
                 break;
         }
         // Keep a copy of the original request
         $error->request = clone $request;
         // get a count of the number of exceptions encountered
         $this->_exceptionCountAtFirstEncounter = count($exceptions);
         // Forward to the error handler
         $request->setParam('error_handler', $error)->setControllerName($this->getErrorHandlerController())->setActionName($this->getErrorHandlerAction())->setDispatched(false);
     }
 }
Exemplo n.º 5
0
 /**
  * Retrieve Front Controller
  *
  * @return Zend_Controller_Front
  */
 public function getFrontController()
 {
     // Used cache version if found
     if (null !== $this->_frontController) {
         return $this->_frontController;
     }
     // Grab singleton instance, if class has been loaded
     if (class_exists('BxZender_Controller_Bitrix')) {
         $this->_frontController = BxZender_Controller_Bitrix::getInstance();
         return $this->_frontController;
     }
     // Throw exception in all other cases
     require_once 'Zend/Controller/Exception.php';
     throw new Zend_Controller_Exception('Front controller class has not been loaded');
 }