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-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2015 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: Abstract.php 24593 2012-01-05 20:35:02Z matthew $ |
20 * @version $Id$ |
21 */ |
21 */ |
22 |
|
23 |
22 |
24 /** Zend_Controller_Router_Interface */ |
23 /** Zend_Controller_Router_Interface */ |
25 require_once 'Zend/Controller/Router/Interface.php'; |
24 require_once 'Zend/Controller/Router/Interface.php'; |
26 |
25 |
27 /** |
26 /** |
29 * with rules-based URI processor. |
28 * with rules-based URI processor. |
30 * |
29 * |
31 * @category Zend |
30 * @category Zend |
32 * @package Zend_Controller |
31 * @package Zend_Controller |
33 * @subpackage Router |
32 * @subpackage Router |
34 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
33 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 */ |
35 */ |
37 abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router_Interface |
36 abstract class Zend_Controller_Router_Abstract implements Zend_Controller_Router_Interface |
38 { |
37 { |
39 /** |
38 /** |
40 * URI delimiter |
39 * URI delimiter |
41 */ |
40 */ |
42 const URI_DELIMITER = '/'; |
41 const URI_DELIMITER = '/'; |
43 |
42 |
44 /** |
43 /** |
45 * Front controller instance |
44 * Front controller instance |
|
45 * |
46 * @var Zend_Controller_Front |
46 * @var Zend_Controller_Front |
47 */ |
47 */ |
48 protected $_frontController; |
48 protected $_frontController; |
49 |
49 |
50 /** |
50 /** |
51 * Array of invocation parameters to use when instantiating action |
51 * Array of invocation parameters to use when instantiating action |
52 * controllers |
52 * controllers |
|
53 * |
53 * @var array |
54 * @var array |
54 */ |
55 */ |
55 protected $_invokeParams = array(); |
56 protected $_invokeParams = array(); |
56 |
57 |
57 /** |
58 /** |
58 * Constructor |
59 * Constructor |
59 * |
60 * |
60 * @param array $params |
61 * @param array $params |
61 * @return void |
|
62 */ |
62 */ |
63 public function __construct(array $params = array()) |
63 public function __construct(array $params = array()) |
64 { |
64 { |
65 $this->setParams($params); |
65 $this->setParams($params); |
66 } |
66 } |
67 |
67 |
68 /** |
68 /** |
69 * Add or modify a parameter to use when instantiating an action controller |
69 * Add or modify a parameter to use when instantiating an action controller |
70 * |
70 * |
71 * @param string $name |
71 * @param string $name |
72 * @param mixed $value |
72 * @param mixed $value |
73 * @return Zend_Controller_Router |
73 * @return Zend_Controller_Router_Abstract |
74 */ |
74 */ |
75 public function setParam($name, $value) |
75 public function setParam($name, $value) |
76 { |
76 { |
77 $name = (string) $name; |
77 $name = (string)$name; |
78 $this->_invokeParams[$name] = $value; |
78 $this->_invokeParams[$name] = $value; |
|
79 |
79 return $this; |
80 return $this; |
80 } |
81 } |
81 |
82 |
82 /** |
83 /** |
83 * Set parameters to pass to action controller constructors |
84 * Set parameters to pass to action controller constructors |
84 * |
85 * |
85 * @param array $params |
86 * @param array $params |
86 * @return Zend_Controller_Router |
87 * @return Zend_Controller_Router_Abstract |
87 */ |
88 */ |
88 public function setParams(array $params) |
89 public function setParams(array $params) |
89 { |
90 { |
90 $this->_invokeParams = array_merge($this->_invokeParams, $params); |
91 $this->_invokeParams = array_merge($this->_invokeParams, $params); |
|
92 |
91 return $this; |
93 return $this; |
92 } |
94 } |
93 |
95 |
94 /** |
96 /** |
95 * Retrieve a single parameter from the controller parameter stack |
97 * Retrieve a single parameter from the controller parameter stack |
122 * By default, clears all parameters. If a parameter name is given, clears |
124 * By default, clears all parameters. If a parameter name is given, clears |
123 * only that parameter; if an array of parameter names is provided, clears |
125 * only that parameter; if an array of parameter names is provided, clears |
124 * each. |
126 * each. |
125 * |
127 * |
126 * @param null|string|array single key or array of keys for params to clear |
128 * @param null|string|array single key or array of keys for params to clear |
127 * @return Zend_Controller_Router |
129 * @return Zend_Controller_Router_Abstract |
128 */ |
130 */ |
129 public function clearParams($name = null) |
131 public function clearParams($name = null) |
130 { |
132 { |
131 if (null === $name) { |
133 if (null === $name) { |
132 $this->_invokeParams = array(); |
134 $this->_invokeParams = array(); |