web/lib/Zend/Controller/Router/Route.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 Router
    17  * @subpackage Router
    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  * @version    $Id: Route.php 20096 2010-01-06 02:05:09Z bkarwin $
    19  * @version    $Id: Route.php 24593 2012-01-05 20:35:02Z matthew $
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  */
    21  */
    22 
    22 
    23 /** Zend_Controller_Router_Route_Abstract */
    23 /** Zend_Controller_Router_Route_Abstract */
    24 require_once 'Zend/Controller/Router/Route/Abstract.php';
    24 require_once 'Zend/Controller/Router/Route/Abstract.php';
    26 /**
    26 /**
    27  * Route
    27  * Route
    28  *
    28  *
    29  * @package    Zend_Controller
    29  * @package    Zend_Controller
    30  * @subpackage Router
    30  * @subpackage Router
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    33  * @see        http://manuals.rubyonrails.com/read/chapter/65
    33  * @see        http://manuals.rubyonrails.com/read/chapter/65
    34  */
    34  */
    35 class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
    35 class Zend_Controller_Router_Route extends Zend_Controller_Router_Route_Abstract
    36 {
    36 {
    75      * @var array
    75      * @var array
    76      */
    76      */
    77     protected $_translatable = array();
    77     protected $_translatable = array();
    78 
    78 
    79     protected $_urlVariable = ':';
    79     protected $_urlVariable = ':';
    80     protected $_urlDelimiter = '/';
    80     protected $_urlDelimiter = self::URI_DELIMITER;
    81     protected $_regexDelimiter = '#';
    81     protected $_regexDelimiter = '#';
    82     protected $_defaultRegex = null;
    82     protected $_defaultRegex = null;
    83 
    83 
    84     /**
    84     /**
    85      * Holds names of all route's pattern variable names. Array index holds a position in URL.
    85      * Holds names of all route's pattern variable names. Array index holds a position in URL.
   292 
   292 
   293         // Check if all map variables have been initialized
   293         // Check if all map variables have been initialized
   294         foreach ($this->_variables as $var) {
   294         foreach ($this->_variables as $var) {
   295             if (!array_key_exists($var, $return)) {
   295             if (!array_key_exists($var, $return)) {
   296                 return false;
   296                 return false;
       
   297             } elseif ($return[$var] == '' || $return[$var] === null) {
       
   298                 // Empty variable? Replace with the default value.
       
   299                 $return[$var] = $this->_defaults[$var];
   297             }
   300             }
   298         }
   301         }
   299 
   302 
   300         $this->setMatchedPath(rtrim($matchedPath, $this->_urlDelimiter));
   303         $this->setMatchedPath(rtrim($matchedPath, $this->_urlDelimiter));
   301 
   304 
   342                     unset($data[$name]);
   345                     unset($data[$name]);
   343                 } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
   346                 } elseif (!$reset && !$useDefault && isset($this->_values[$name])) {
   344                     $value = $this->_values[$name];
   347                     $value = $this->_values[$name];
   345                 } elseif (!$reset && !$useDefault && isset($this->_wildcardData[$name])) {
   348                 } elseif (!$reset && !$useDefault && isset($this->_wildcardData[$name])) {
   346                     $value = $this->_wildcardData[$name];
   349                     $value = $this->_wildcardData[$name];
   347                 } elseif (isset($this->_defaults[$name])) {
   350                 } elseif (array_key_exists($name, $this->_defaults)) {
   348                     $value = $this->_defaults[$name];
   351                     $value = $this->_defaults[$name];
   349                 } else {
   352                 } else {
   350                     require_once 'Zend/Controller/Router/Exception.php';
   353                     require_once 'Zend/Controller/Router/Exception.php';
   351                     throw new Zend_Controller_Router_Exception($name . ' is not specified');
   354                     throw new Zend_Controller_Router_Exception($name . ' is not specified');
   352                 }
   355                 }