ENHANCEMENT Added RequestHandler->setRequest() for easier testing of controllers (usually handled through handleRequest()). Moved $request definition from Controller into parent class (RequestHandler)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@115108 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-12-16 02:36:31 +00:00
parent e8c8c9472a
commit 9681134e8e
2 changed files with 15 additions and 16 deletions

View File

@ -51,12 +51,6 @@ class Controller extends RequestHandler {
*/
protected $response;
/**
* @var SS_HTTPRequest $request The request object that the controller was called with.
* Set in {@link handleRequest()}. Useful to generate the {}
*/
protected $request;
/**
* Default URL handlers - (Action)/(ID)/(OtherID)
*/
@ -222,16 +216,6 @@ class Controller extends RequestHandler {
return $this->response;
}
/**
* Get the request with which this controller was called (if any).
* Usually set in {@link handleRequest()}.
*
* @return SS_HTTPRequest
*/
function getRequest() {
return $this->request;
}
protected $baseInitCalled = false;
/**

View File

@ -29,6 +29,11 @@
* @subpackage control
*/
class RequestHandler extends ViewableData {
/**
* @var SS_HTTPRequest $request The request object that the controller was called with.
* Set in {@link handleRequest()}. Useful to generate the {}
*/
protected $request = null;
/**
@ -318,4 +323,14 @@ class RequestHandler extends ViewableData {
function getRequest() {
return $this->request;
}
/**
* Typically the request is set through {@link handleAction()}
* or {@link handleRequest()}, but in some based we want to set it manually.
*
* @param SS_HTTPRequest
*/
function setRequest($request) {
$this->request = $request;
}
}