From 9681134e8ebfa84d2125c80c3ba8834d83b2bdc2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 16 Dec 2010 02:36:31 +0000 Subject: [PATCH] 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 --- core/control/Controller.php | 16 ---------------- core/control/RequestHandler.php | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/control/Controller.php b/core/control/Controller.php index dd77c2079..4f959bd87 100755 --- a/core/control/Controller.php +++ b/core/control/Controller.php @@ -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; /** diff --git a/core/control/RequestHandler.php b/core/control/RequestHandler.php index 60094a36b..f2acb19fc 100755 --- a/core/control/RequestHandler.php +++ b/core/control/RequestHandler.php @@ -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; + } }