Пример #1
0
 /**
  * Retrieves custom controller name
  *  
  * @param IfwPsn_Vendor_Zend_Controller_Request_Abstract $request
  * @return string|boolean
  */
 protected function _getCustomController($request)
 {
     $controllerName = $this->_pm->getAbbr() . '-' . $request->get('controller');
     return $controllerName;
 }
Пример #2
0
 /**
  * Dispatch to a controller/action
  *
  * By default, if a controller is not dispatchable, dispatch() will throw
  * an exception. If you wish to use the default controller instead, set the
  * param 'useDefaultControllerAlways' via {@link setParam()}.
  *
  * @param IfwPsn_Vendor_Zend_Controller_Request_Abstract $request
  * @param IfwPsn_Vendor_Zend_Controller_Response_Abstract $response
  * @throws IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception
  * @throws Exception
  * @return void
  */
 public function dispatch(IfwPsn_Vendor_Zend_Controller_Request_Abstract $request, IfwPsn_Vendor_Zend_Controller_Response_Abstract $response)
 {
     $this->setResponse($response);
     if (!$this->_controller instanceof IfwPsn_Vendor_Zend_Controller_Action_Interface or !strpos(strtolower($request->getControllerName()), strtolower($request->get('controller')))) {
         // if controller is not initialized by initController already or on error/excption
         /**
          * Get controller class
          */
         if (!$this->isDispatchable($request)) {
             $controller = $request->getControllerName();
             if (!$this->getParam('useDefaultControllerAlways') && !empty($controller)) {
                 //require_once 'IfwZend/Controller/Dispatcher/Exception.php';
                 throw new IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception('Invalid controller specified (' . $request->getControllerName() . ')');
             }
             $className = $this->getDefaultControllerClass($request);
         } else {
             $className = $this->getControllerClass($request);
             if (!$className) {
                 $className = $this->getDefaultControllerClass($request);
             }
         }
         /**
          * Load the controller class file
          */
         $className = $this->loadClass($className);
         /**
          * Instantiate controller with request, response, and invocation
          * arguments; throw exception if it's not an action controller
          */
         $this->_controller = new $className($request, $this->getResponse(), $this->getParams());
         if (!$this->_controller instanceof IfwPsn_Vendor_Zend_Controller_Action_Interface && !$this->_controller instanceof IfwPsn_Vendor_Zend_Controller_Action) {
             //require_once 'IfwZend/Controller/Dispatcher/Exception.php';
             throw new IfwPsn_Vendor_Zend_Controller_Dispatcher_Exception('Controller "' . $className . '" is not an instance of IfwPsn_Vendor_Zend_Controller_Action_Interface');
         }
     }
     /**
      * Retrieve the action name
      */
     $action = $this->getActionMethod($request);
     /**
      * Dispatch the method call
      */
     $request->setDispatched(true);
     // by default, buffer output
     $disableOb = $this->getParam('disableOutputBuffering');
     $obLevel = ob_get_level();
     if (empty($disableOb)) {
         ob_start();
     }
     try {
         $this->_pm->getLogger()->logPrefixed(sprintf('Dispatching action %s on controller %s', $action, get_class($this->_controller)));
         $this->_controller->dispatch($action);
     } catch (Exception $e) {
         // Clean output buffer on error
         $curObLevel = ob_get_level();
         if ($curObLevel > $obLevel) {
             do {
                 ob_get_clean();
                 $curObLevel = ob_get_level();
             } while ($curObLevel > $obLevel);
         }
         throw $e;
     }
     if (empty($disableOb)) {
         $content = ob_get_clean();
         $response->appendBody($content);
     }
     // Destroy the page controller instance and reflection objects
     $this->_controller = null;
 }
Пример #3
0
 /**
  * @param string $name
  * @param array $arguments
  */
 public function __call($name, $arguments)
 {
     $controller = $this->_request->get('controller');
     $controller = esc_attr($controller);
     IfwPsn_Wp_Proxy_Action::doAction($this->_pm->getAbbrLower() . '_' . $controller . '_action-' . str_replace('Action', '', $name), $this, $arguments);
 }