mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
e8c8c9472a
commit
9681134e8e
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user