mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: Added method for $this->request->latestParam() backwards compatibility with Director::urlParam()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@105890 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ca9f32f9ec
commit
3bbcb31364
@ -275,8 +275,6 @@ class Director {
|
||||
return "redirect:" . Director::absoluteURL($arguments['Redirect'], true);
|
||||
|
||||
} else {
|
||||
Director::$urlParams = $arguments;
|
||||
|
||||
$controllerObj = new $controller();
|
||||
$controllerObj->setSession($session);
|
||||
|
||||
@ -294,18 +292,31 @@ class Director {
|
||||
|
||||
/**
|
||||
* Returns the urlParam with the given name
|
||||
*
|
||||
* @deprecated 3.0 Use SS_HTTPRequest->latestParam()
|
||||
*/
|
||||
static function urlParam($name) {
|
||||
if(isset(Director::$urlParams[$name])) return Director::$urlParams[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of urlParams
|
||||
* Returns an array of urlParams.
|
||||
*
|
||||
* @deprecated 3.0 Use SS_HTTPRequest->latestParams()
|
||||
*/
|
||||
static function urlParams() {
|
||||
return Director::$urlParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set url parameters (should only be called internally by RequestHandler->handleRequest()).
|
||||
*
|
||||
* @param $params array
|
||||
*/
|
||||
static function setUrlParams($params) {
|
||||
Director::$urlParams = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link SiteTree} object that is currently being viewed. If there is no sitetree object to return,
|
||||
* then this will return the current controller.
|
||||
|
@ -115,6 +115,9 @@ class RequestHandler extends ViewableData {
|
||||
// FIXME: This unnecessary coupling was added to fix a bug in Image_Uploader.
|
||||
if($this instanceof Controller) $this->urlParams = $request->allParams();
|
||||
|
||||
// Backwards compatible setting of url parameters, please use SS_HTTPRequest->latestParam() instead
|
||||
Director::setUrlParams($request->latestParams());
|
||||
|
||||
if(isset($_REQUEST['debug_request'])) {
|
||||
Debug::message("Rule '$rule' matched to action '$action' on $this->class. Latest request params: " . var_export($request->latestParams(), true));
|
||||
}
|
||||
|
@ -7,6 +7,23 @@
|
||||
class RequestHandlingTest extends SapphireTest {
|
||||
static $fixture_file = null;
|
||||
|
||||
// function testRequestHandlerChainingLatestParams() {
|
||||
// $c = new RequestHandlingTest_Controller();
|
||||
// $c->init();
|
||||
// $response = $c->handleRequest(new SS_HTTPRequest('GET', 'testGoodBase1/TestForm/fields/MyField'));
|
||||
// $this->assertEquals(
|
||||
// $c->getRequest()->latestParams(),
|
||||
// array(
|
||||
// 'Action' => 'fields',
|
||||
// 'ID' => 'MyField'
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
function testRequestHandlerChainingAllParams() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
function testMethodCallingOnController() {
|
||||
/* Calling a controller works just like it always has */
|
||||
$response = Director::test("testGoodBase1");
|
||||
|
Loading…
Reference in New Issue
Block a user