web/lib/Zend/Controller/Dispatcher/Standard.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Controller
    16  * @package    Zend_Controller
    17  * @subpackage Dispatcher
    17  * @subpackage Dispatcher
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Standard.php 22038 2010-04-28 18:54:22Z matthew $
    20  * @version    $Id: Standard.php 24861 2012-06-01 23:40:13Z adamlundrigan $
    21  */
    21  */
    22 
    22 
    23 /** Zend_Loader */
    23 /** Zend_Loader */
    24 require_once 'Zend/Loader.php';
    24 require_once 'Zend/Loader.php';
    25 
    25 
    28 
    28 
    29 /**
    29 /**
    30  * @category   Zend
    30  * @category   Zend
    31  * @package    Zend_Controller
    31  * @package    Zend_Controller
    32  * @subpackage Dispatcher
    32  * @subpackage Dispatcher
    33  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    33  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    35  */
    35  */
    36 class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abstract
    36 class Zend_Controller_Dispatcher_Standard extends Zend_Controller_Dispatcher_Abstract
    37 {
    37 {
    38     /**
    38     /**
   255                 $className = $this->getDefaultControllerClass($request);
   255                 $className = $this->getDefaultControllerClass($request);
   256             }
   256             }
   257         }
   257         }
   258 
   258 
   259         /**
   259         /**
       
   260          * If we're in a module or prefixDefaultModule is on, we must add the module name
       
   261          * prefix to the contents of $className, as getControllerClass does not do that automatically.
       
   262          * We must keep a separate variable because modules are not strictly PSR-0: We need the no-module-prefix
       
   263          * class name to do the class->file mapping, but the full class name to insantiate the controller
       
   264          */
       
   265         $moduleClassName = $className;
       
   266         if (($this->_defaultModule != $this->_curModule)
       
   267             || $this->getParam('prefixDefaultModule'))
       
   268         {
       
   269             $moduleClassName = $this->formatClassName($this->_curModule, $className);
       
   270         }
       
   271 
       
   272         /**
   260          * Load the controller class file
   273          * Load the controller class file
   261          */
   274          */
   262         $className = $this->loadClass($className);
   275         $className = $this->loadClass($className);
   263 
   276 
   264         /**
   277         /**
   265          * Instantiate controller with request, response, and invocation
   278          * Instantiate controller with request, response, and invocation
   266          * arguments; throw exception if it's not an action controller
   279          * arguments; throw exception if it's not an action controller
   267          */
   280          */
   268         $controller = new $className($request, $this->getResponse(), $this->getParams());
   281         $controller = new $moduleClassName($request, $this->getResponse(), $this->getParams());
   269         if (!($controller instanceof Zend_Controller_Action_Interface) &&
   282         if (!($controller instanceof Zend_Controller_Action_Interface) &&
   270             !($controller instanceof Zend_Controller_Action)) {
   283             !($controller instanceof Zend_Controller_Action)) {
   271             require_once 'Zend/Controller/Dispatcher/Exception.php';
   284             require_once 'Zend/Controller/Dispatcher/Exception.php';
   272             throw new Zend_Controller_Dispatcher_Exception(
   285             throw new Zend_Controller_Dispatcher_Exception(
   273                 'Controller "' . $className . '" is not an instance of Zend_Controller_Action_Interface'
   286                 'Controller "' . $moduleClassName . '" is not an instance of Zend_Controller_Action_Interface'
   274             );
   287             );
   275         }
   288         }
   276 
   289 
   277         /**
   290         /**
   278          * Retrieve the action name
   291          * Retrieve the action name