File indexing completed on 2024-12-22 05:36:28
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Application 0017 * @subpackage Resource 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Application_Resource_ResourceAbstract 0025 */ 0026 // require_once 'Zend/Application/Resource/ResourceAbstract.php'; 0027 0028 0029 /** 0030 * Resource for initializing the locale 0031 * 0032 * @uses Zend_Application_Resource_Base 0033 * @category Zend 0034 * @package Zend_Application 0035 * @subpackage Resource 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Application_Resource_Router 0040 extends Zend_Application_Resource_ResourceAbstract 0041 { 0042 /** 0043 * @var Zend_Controller_Router_Rewrite 0044 */ 0045 protected $_router; 0046 0047 /** 0048 * Defined by Zend_Application_Resource_Resource 0049 * 0050 * @return Zend_Controller_Router_Rewrite 0051 */ 0052 public function init() 0053 { 0054 return $this->getRouter(); 0055 } 0056 0057 /** 0058 * Retrieve router object 0059 * 0060 * @return Zend_Controller_Router_Rewrite 0061 */ 0062 public function getRouter() 0063 { 0064 if (null === $this->_router) { 0065 $bootstrap = $this->getBootstrap(); 0066 $bootstrap->bootstrap('FrontController'); 0067 $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter(); 0068 0069 $options = $this->getOptions(); 0070 if (!isset($options['routes'])) { 0071 $options['routes'] = array(); 0072 } 0073 0074 if (isset($options['chainNameSeparator'])) { 0075 $this->_router->setChainNameSeparator($options['chainNameSeparator']); 0076 } 0077 0078 if (isset($options['useRequestParametersAsGlobal'])) { 0079 $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']); 0080 } 0081 0082 $this->_router->addConfig(new Zend_Config($options['routes'])); 0083 } 0084 0085 return $this->_router; 0086 } 0087 }