Index: library/Zend/Controller/Action.php =================================================================== --- library/Zend/Controller/Action.php (revision 14725) +++ library/Zend/Controller/Action.php (working copy) @@ -578,6 +578,22 @@ */ protected function _getParam($paramName, $default = null) { + return $this->getParam($paramName, $default); + } + + /** + * Gets a parameter from the {@link $_request Request object}. If the + * parameter does not exist, NULL will be returned. + * + * If the parameter does not exist and $default is set, then + * $default will be returned instead of NULL. + * + * @param string $paramName + * @param mixed $default + * @return mixed + */ + public function getParam($paramName, $default = null) + { $value = $this->getRequest()->getParam($paramName); if ((null == $value) && (null !== $default)) { $value = $default; @@ -592,9 +608,23 @@ * @param string $paramName * @param mixed $value * @return Zend_Controller_Action + * @deprecated Deprecated as of Zend Framework 1.7. Use + * setParam() instead. */ protected function _setParam($paramName, $value) { + return $this->setParam($paramName, $value); + } + + /** + * Set a parameter in the {@link $_request Request object}. + * + * @param string $paramName + * @param mixed $value + * @return Zend_Controller_Action + */ + public function setParam($paramName, $value) + { $this->getRequest()->setParam($paramName, $value); return $this; @@ -606,9 +636,23 @@ * * @param string $paramName * @return boolean + * @deprecated Deprecated as of Zend Framework 1.7. Use + * hasParam() instead. */ protected function _hasParam($paramName) { + return $this->hasParam($paramName); + } + + /** + * Determine whether a given parameter exists in the + * {@link $_request Request object}. + * + * @param string $paramName + * @return boolean + */ + public function hasParam($paramName) + { return null !== $this->getRequest()->getParam($paramName); } @@ -617,9 +661,22 @@ * as an associative array. * * @return array + * @deprecated Deprecated as of Zend Framework 1.7. Use + * getAllParams() instead. */ protected function _getAllParams() { + return $this->getAllParams(); + } + + /** + * Return all parameters in the {@link $_request Request object} + * as an associative array. + * + * @return array + */ + public function getAllParams() + { return $this->getRequest()->getParams(); } @@ -649,9 +706,42 @@ * @param string $module * @param array $params * @return void + * @deprecated Deprecated as of Zend Framework 1.7. Use + * forward() instead. */ final protected function _forward($action, $controller = null, $module = null, array $params = null) { + $this->forward($action, $controller, $module, $params); + } + + /** + * Forward to another controller/action. + * + * It is important to supply the unformatted names, i.e. "article" + * rather than "ArticleController". The dispatcher will do the + * appropriate formatting when the request is received. + * + * If only an action name is provided, forwards to that action in this + * controller. + * + * If an action and controller are specified, forwards to that action and + * controller in this module. + * + * Specifying an action, controller, and module is the most specific way to + * forward. + * + * A fourth argument, $params, will be used to set the request parameters. + * If either the controller or module are unnecessary for forwarding, + * simply pass null values for them before specifying the parameters. + * + * @param string $action + * @param string $controller + * @param string $module + * @param array $params + * @return void + */ + final public function forward($action, $controller = null, $module = null, array $params = null) + { $request = $this->getRequest(); if (null !== $params) { @@ -679,9 +769,25 @@ * @param string $url * @param array $options Options to be used when redirecting * @return void + * @deprecated Deprecated as of Zend Framework 1.7. Use + * redirect() instead. */ protected function _redirect($url, array $options = array()) { + $this->redirect($url, $options); + } + + /** + * Redirect to another URL + * + * Proxies to {@link Zend_Controller_Action_Helper_Redirector::gotoUrl()}. + * + * @param string $url + * @param array $options Options to be used when redirecting + * @return void + */ + public function redirect($url, array $options = array()) + { $this->_helper->redirector->gotoUrl($url, $options); } } Index: tests/Zend/Controller/ActionTest.php =================================================================== --- tests/Zend/Controller/ActionTest.php (revision 14725) +++ tests/Zend/Controller/ActionTest.php (working copy) @@ -14,7 +14,7 @@ require_once 'Zend/Controller/Request/Http.php'; require_once 'Zend/Controller/Response/Cli.php'; -class Zend_Controller_ActionTest extends PHPUnit_Framework_TestCase +class Zend_Controller_ActionTest extends PHPUnit_Framework_TestCase { /** * Runs the test methods of this class. @@ -169,7 +169,7 @@ $this->fail('Should not be able to call bar as action'); } catch (Exception $e) { //success! - } + } } public function testRun3() @@ -193,7 +193,7 @@ public function testSetParam() { $this->_controller->setParam('foo', 'bar'); - $params = $this->_controller->getParams(); + $params = $this->_controller->getAllParams(); $this->assertTrue(isset($params['foo'])); $this->assertEquals('bar', $params['foo']); } @@ -204,7 +204,7 @@ $this->_controller->setParam('bar', 'baz'); $this->_controller->setParam('boo', 'bah'); - $params = $this->_controller->getParams(); + $params = $this->_controller->getAllParams(); $this->assertEquals('bar', $params['foo']); $this->assertEquals('baz', $params['bar']); $this->assertEquals('bah', $params['boo']); @@ -492,32 +492,6 @@ { $this->getResponse()->setBody("Should never see this\n"); } - - public function forward($action, $controller = null, $module = null, array $params = null) - { - $this->_forward($action, $controller, $module, $params); - } - - public function hasParam($param) - { - return $this->_hasParam($param); - } - - public function getParams() - { - return $this->_getAllParams(); - } - - public function setParam($key, $value) - { - $this->_setParam($key, $value); - return $this; - } - - public function redirect($url, $code = 302, $prependBase = true) - { - $this->_redirect($url, array('code' => $code, 'prependBase' => $prependBase)); - } } // Call Zend_Controller_ActionTest::main() if this source file is executed directly.