web/lib/Zend/Application/Resource/Router.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Application
       
    17  * @subpackage Resource
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Router.php 20814 2010-02-01 20:13:08Z freak $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Application_Resource_ResourceAbstract
       
    25  */
       
    26 require_once 'Zend/Application/Resource/ResourceAbstract.php';
       
    27 
       
    28 
       
    29 /**
       
    30  * Resource for initializing the locale
       
    31  *
       
    32  * @uses       Zend_Application_Resource_Base
       
    33  * @category   Zend
       
    34  * @package    Zend_Application
       
    35  * @subpackage Resource
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_Application_Resource_Router
       
    40     extends Zend_Application_Resource_ResourceAbstract
       
    41 {
       
    42     /**
       
    43      * @var Zend_Controller_Router_Rewrite
       
    44      */
       
    45     protected $_router;
       
    46 
       
    47     /**
       
    48      * Defined by Zend_Application_Resource_Resource
       
    49      *
       
    50      * @return Zend_Controller_Router_Rewrite
       
    51      */
       
    52     public function init()
       
    53     {
       
    54         return $this->getRouter();
       
    55     }
       
    56 
       
    57     /**
       
    58      * Retrieve router object
       
    59      *
       
    60      * @return Zend_Controller_Router_Rewrite
       
    61      */
       
    62     public function getRouter()
       
    63     {
       
    64         if (null === $this->_router) {
       
    65             $bootstrap = $this->getBootstrap();
       
    66             $bootstrap->bootstrap('FrontController');
       
    67             $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter();
       
    68 
       
    69             $options = $this->getOptions();
       
    70             if (!isset($options['routes'])) {
       
    71                 $options['routes'] = array();
       
    72             }
       
    73 
       
    74             if (isset($options['chainNameSeparator'])) {
       
    75                 $this->_router->setChainNameSeparator($options['chainNameSeparator']);
       
    76             }
       
    77 
       
    78             if (isset($options['useRequestParametersAsGlobal'])) {
       
    79                 $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']);
       
    80             }
       
    81 
       
    82             $this->_router->addConfig(new Zend_Config($options['routes']));
       
    83         }
       
    84 
       
    85         return $this->_router;
       
    86     }
       
    87 }