Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 9681134e8ebfa84d2125c80c3ba8834d83b2bdc2 1 parent e8c8c94
@chillu chillu authored
Showing with 15 additions and 16 deletions.
  1. +0 −16 core/control/Controller.php
  2. +15 −0 core/control/RequestHandler.php
View
16 core/control/Controller.php
@@ -52,12 +52,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)
*/
static $url_handlers = array(
@@ -222,16 +216,6 @@ function getResponse() {
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
15 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 @@ public function httpError($errorCode, $errorMessage = null) {
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;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.