mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE #2857 - Renamed RequestHandlingData to RequestHandler
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64953 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
185f81492e
commit
cd699e3d89
@ -9,7 +9,7 @@
|
|||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage control
|
* @subpackage control
|
||||||
*/
|
*/
|
||||||
class Controller extends RequestHandlingData {
|
class Controller extends RequestHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $urlParams An array of arguments extracted from the URL
|
* @var array $urlParams An array of arguments extracted from the URL
|
||||||
|
@ -77,8 +77,8 @@ class Director {
|
|||||||
* request.
|
* request.
|
||||||
* - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, and call the rule
|
* - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, and call the rule
|
||||||
* handling method.
|
* handling method.
|
||||||
* - RequestHandlingData::handleRequest($request) is recursively called whenever a rule handling method returns a
|
* - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method returns a
|
||||||
* RequestHandlingData object.
|
* RequestHandler object.
|
||||||
*
|
*
|
||||||
* In addition to request processing, Director will manage the session, and perform the output of the actual response
|
* In addition to request processing, Director will manage the session, and perform the output of the actual response
|
||||||
* to the browser.
|
* to the browser.
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a HTTP-request, including a URL that is tokenised for parsing, and a request method (GET/POST/PUT/DELETE).
|
* Represents a HTTP-request, including a URL that is tokenised for parsing, and a request method (GET/POST/PUT/DELETE).
|
||||||
* This is used by {@link RequestHandlingData} objects to decide what to do.
|
* This is used by {@link RequestHandler} objects to decide what to do.
|
||||||
*
|
*
|
||||||
* The intention is that a single HTTPRequest object can be passed from one object to another, each object calling
|
* The intention is that a single HTTPRequest object can be passed from one object to another, each object calling
|
||||||
* match() to get the information that they need out of the URL. This is generally handled by
|
* match() to get the information that they need out of the URL. This is generally handled by
|
||||||
* {@link RequestHandlingData::handleRequest()}.
|
* {@link RequestHandler::handleRequest()}.
|
||||||
*
|
*
|
||||||
* @todo Accept X_HTTP_METHOD_OVERRIDE http header and $_REQUEST['_method'] to override request types (useful for webclients
|
* @todo Accept X_HTTP_METHOD_OVERRIDE http header and $_REQUEST['_method'] to override request types (useful for webclients
|
||||||
* not supporting PUT and DELETE)
|
* not supporting PUT and DELETE)
|
||||||
@ -66,7 +66,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $allParams Contains an assiciative array of all
|
* @var array $allParams Contains an assiciative array of all
|
||||||
* arguments matched in all calls to {@link RequestHandlingData->handleRequest()}.
|
* arguments matched in all calls to {@link RequestHandler->handleRequest()}.
|
||||||
* Its a "historical record" thats specific to the current call of
|
* Its a "historical record" thats specific to the current call of
|
||||||
* {@link handleRequest()}, and is only complete once the "last call" to that method is made.
|
* {@link handleRequest()}, and is only complete once the "last call" to that method is made.
|
||||||
*/
|
*/
|
||||||
@ -74,10 +74,10 @@ class HTTPRequest extends Object implements ArrayAccess {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $latestParams Contains an associative array of all
|
* @var array $latestParams Contains an associative array of all
|
||||||
* arguments matched in the current call from {@link RequestHandlingData->handleRequest()},
|
* arguments matched in the current call from {@link RequestHandler->handleRequest()},
|
||||||
* as denoted with a "$"-prefix in the $url_handlers definitions.
|
* as denoted with a "$"-prefix in the $url_handlers definitions.
|
||||||
* Contains different states throughout its lifespan, so just useful
|
* Contains different states throughout its lifespan, so just useful
|
||||||
* while processed in {@link RequestHandlingData} and to get the last
|
* while processed in {@link RequestHandler} and to get the last
|
||||||
* processes arguments.
|
* processes arguments.
|
||||||
*/
|
*/
|
||||||
protected $latestParams = array();
|
protected $latestParams = array();
|
||||||
@ -330,7 +330,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
|||||||
if($varRequired && !isset($this->dirParts[$i])) return false;
|
if($varRequired && !isset($this->dirParts[$i])) return false;
|
||||||
|
|
||||||
$arguments[$varName] = isset($this->dirParts[$i]) ? $this->dirParts[$i] : null;
|
$arguments[$varName] = isset($this->dirParts[$i]) ? $this->dirParts[$i] : null;
|
||||||
if($part == '$Controller' && (!class_exists($arguments['Controller']) || !is_subclass_of($arguments['Controller'], 'RequestHandlingData'))) {
|
if($part == '$Controller' && (!class_exists($arguments['Controller']) || !is_subclass_of($arguments['Controller'], 'RequestHandler'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unparsed part of the original URL
|
* Returns the unparsed part of the original URL
|
||||||
* separated by commas. This is used by {@link RequestHandlingData->handleRequest()}
|
* separated by commas. This is used by {@link RequestHandler->handleRequest()}
|
||||||
* to determine if further URL processing is necessary.
|
* to determine if further URL processing is necessary.
|
||||||
*
|
*
|
||||||
* @return string Partial URL
|
* @return string Partial URL
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* This class is the base class of any Sapphire object that can be used to handle HTTP requests.
|
* This class is the base class of any Sapphire object that can be used to handle HTTP requests.
|
||||||
*
|
*
|
||||||
* Any RequestHandlingData object can be made responsible for handling its own segment of the URL namespace.
|
* Any RequestHandler object can be made responsible for handling its own segment of the URL namespace.
|
||||||
* The {@link Director} begins the URL parsing process; it will parse the beginning of the URL to identify which
|
* The {@link Director} begins the URL parsing process; it will parse the beginning of the URL to identify which
|
||||||
* controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters that it
|
* controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters that it
|
||||||
* parsed from the URL, and the {@link HTTPRequest} that contains the remainder of the URL to be parsed.
|
* parsed from the URL, and the {@link HTTPRequest} that contains the remainder of the URL to be parsed.
|
||||||
@ -17,15 +17,15 @@
|
|||||||
* - Director will determine that admin/crm is controlled by a new ModelAdmin object, and pass control to that.
|
* - Director will determine that admin/crm is controlled by a new ModelAdmin object, and pass control to that.
|
||||||
* Matching Director Rule: "admin/crm" => "ModelAdmin" (defined in mysite/_config.php)
|
* Matching Director Rule: "admin/crm" => "ModelAdmin" (defined in mysite/_config.php)
|
||||||
* - ModelAdmin will determine that SearchForm is controlled by a Form object returned by $this->SearchForm(), and pass control to that.
|
* - ModelAdmin will determine that SearchForm is controlled by a Form object returned by $this->SearchForm(), and pass control to that.
|
||||||
* Matching $url_handlers: "$Action" => "$Action" (defined in RequestHandlingData class)
|
* Matching $url_handlers: "$Action" => "$Action" (defined in RequestHandler class)
|
||||||
* - Form will determine that field/Groups is controlled by the Groups field, a TreeMultiselectField, and pass control to that.
|
* - Form will determine that field/Groups is controlled by the Groups field, a TreeMultiselectField, and pass control to that.
|
||||||
* Matching $url_handlers: 'field/$FieldName!' => 'handleField' (defined in Form class)
|
* Matching $url_handlers: 'field/$FieldName!' => 'handleField' (defined in Form class)
|
||||||
* - TreeMultiselectField will determine that treesegment/36 is handled by its treesegment() method. This method will return an HTML fragment that is output to the screen.
|
* - TreeMultiselectField will determine that treesegment/36 is handled by its treesegment() method. This method will return an HTML fragment that is output to the screen.
|
||||||
* Matching $url_handlers: "$Action/$ID" => "handleItem" (defined in TreeMultiSelectField class)
|
* Matching $url_handlers: "$Action/$ID" => "handleItem" (defined in TreeMultiSelectField class)
|
||||||
*
|
*
|
||||||
* {@link RequestHandlingData::handleRequest()} is where this behaviour is implemented.
|
* {@link RequestHandler::handleRequest()} is where this behaviour is implemented.
|
||||||
*/
|
*/
|
||||||
class RequestHandlingData extends ViewableData {
|
class RequestHandler extends ViewableData {
|
||||||
protected $request = null;
|
protected $request = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +72,7 @@ class RequestHandlingData extends ViewableData {
|
|||||||
* @param $request The {@link HTTPRequest} object that is reponsible for distributing URL parsing
|
* @param $request The {@link HTTPRequest} object that is reponsible for distributing URL parsing
|
||||||
* @uses HTTPRequest
|
* @uses HTTPRequest
|
||||||
* @uses HTTPRequest->match()
|
* @uses HTTPRequest->match()
|
||||||
* @return HTTPResponse|RequestHandlingData|string|array
|
* @return HTTPResponse|RequestHandler|string|array
|
||||||
*/
|
*/
|
||||||
function handleRequest($request) {
|
function handleRequest($request) {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
@ -107,10 +107,10 @@ class RequestHandlingData extends ViewableData {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we return a RequestHandlingData, call handleRequest() on that, even if there is no more URL to parse.
|
// If we return a RequestHandler, call handleRequest() on that, even if there is no more URL to parse.
|
||||||
// It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves,
|
// It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves,
|
||||||
// to prevent infinite loops
|
// to prevent infinite loops
|
||||||
if(!$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandlingData) {
|
if(!$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandler) {
|
||||||
$returnValue = $result->handleRequest($request);
|
$returnValue = $result->handleRequest($request);
|
||||||
|
|
||||||
// Array results can be used to handle
|
// Array results can be used to handle
|
||||||
@ -143,7 +143,7 @@ class RequestHandlingData extends ViewableData {
|
|||||||
// Collate self::$allowed_actions from this class and all parent classes
|
// Collate self::$allowed_actions from this class and all parent classes
|
||||||
$access = null;
|
$access = null;
|
||||||
$className = $this->class;
|
$className = $this->class;
|
||||||
while($className != 'RequestHandlingData') {
|
while($className != 'RequestHandler') {
|
||||||
// Merge any non-null parts onto $access.
|
// Merge any non-null parts onto $access.
|
||||||
$accessPart = eval("return $className::\$allowed_actions;");
|
$accessPart = eval("return $className::\$allowed_actions;");
|
||||||
if($accessPart !== null) $access = array_merge((array)$access, $accessPart);
|
if($accessPart !== null) $access = array_merge((array)$access, $accessPart);
|
@ -866,7 +866,7 @@ class SiteTree extends DataObject {
|
|||||||
|
|
||||||
$count = 1;
|
$count = 1;
|
||||||
while (
|
while (
|
||||||
(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandlingData')) ||
|
(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) ||
|
||||||
DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")
|
DataObject::get_one("SiteTree", "URLSegment = '$this->URLSegment' $idFilter")
|
||||||
) {
|
) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* cd /my/project/
|
* cd /my/project/
|
||||||
* sake dev/modules/add ecommerce
|
* sake dev/modules/add ecommerce
|
||||||
*/
|
*/
|
||||||
class ModuleManager extends RequestHandlingData {
|
class ModuleManager extends RequestHandler {
|
||||||
protected $moduleBase = "http://svn.silverstripe.com/open/modules/";
|
protected $moduleBase = "http://svn.silverstripe.com/open/modules/";
|
||||||
|
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
|
@ -587,7 +587,7 @@ JS;
|
|||||||
/**
|
/**
|
||||||
* @todo Tie this into ComplexTableField_Item better.
|
* @todo Tie this into ComplexTableField_Item better.
|
||||||
*/
|
*/
|
||||||
class ComplexTableField_ItemRequest extends RequestHandlingData {
|
class ComplexTableField_ItemRequest extends RequestHandler {
|
||||||
protected $ctf;
|
protected $ctf;
|
||||||
protected $itemID;
|
protected $itemID;
|
||||||
protected $methodName;
|
protected $methodName;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage core
|
* @subpackage core
|
||||||
*/
|
*/
|
||||||
class Form extends RequestHandlingData {
|
class Form extends RequestHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean $includeFormTag Accessed by Form.ss; modified by {@link formHtmlContent()}.
|
* @var boolean $includeFormTag Accessed by Form.ss; modified by {@link formHtmlContent()}.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage core
|
* @subpackage core
|
||||||
*/
|
*/
|
||||||
class FormField extends RequestHandlingData {
|
class FormField extends RequestHandler {
|
||||||
protected $form;
|
protected $form;
|
||||||
protected $name, $title, $value ,$message, $messageType, $extraClass;
|
protected $name, $title, $value ,$message, $messageType, $extraClass;
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ function HtmlEditorField_dataValue_processImage($parts) {
|
|||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage fields-formattedinput
|
* @subpackage fields-formattedinput
|
||||||
*/
|
*/
|
||||||
class HtmlEditorField_Toolbar extends RequestHandlingData {
|
class HtmlEditorField_Toolbar extends RequestHandler {
|
||||||
protected $controller, $name;
|
protected $controller, $name;
|
||||||
|
|
||||||
function __construct($controller, $name) {
|
function __construct($controller, $name) {
|
||||||
|
@ -1333,7 +1333,7 @@ class TableListField_Item extends ViewableData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TableListField_ItemRequest extends RequestHandlingData {
|
class TableListField_ItemRequest extends RequestHandler {
|
||||||
protected $ctf;
|
protected $ctf;
|
||||||
protected $itemID;
|
protected $itemID;
|
||||||
protected $methodName;
|
protected $methodName;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for RequestHandlingData and HTTPRequest.
|
* Tests for RequestHandler and HTTPRequest.
|
||||||
* We've set up a simple URL handling model based on
|
* We've set up a simple URL handling model based on
|
||||||
*/
|
*/
|
||||||
class RequestHandlingTest extends SapphireTest {
|
class RequestHandlingTest extends SapphireTest {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user