diff --git a/src/Control/Director.php b/src/Control/Director.php index 081d1ef42..a44f6198d 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -16,13 +16,13 @@ use SilverStripe\View\TemplateGlobalProvider; /** * Director is responsible for processing URLs, and providing environment information. * - * The most important part of director is {@link Director::direct()}, which is passed a URL and will + * The most important part of director is {@link Director::handleRequest()}, which is passed an HTTPRequest and will * execute the appropriate controller. * * Director also has a number of static methods that provide information about the environment, such as * {@link Director::$environment_type}. * - * @see Director::direct() + * @see Director::handleRequest() * @see Director::$rules * @see Director::$environment_type */ @@ -100,40 +100,10 @@ class Director implements TemplateGlobalProvider protected static $environment_type; /** - * Process the given URL, creating the appropriate controller and executing it. - * - * Request processing is handled as follows: - * - Director::direct() creates a new HTTPResponse object and passes this to - * Director::handleRequest(). - * - Director::handleRequest($request) checks each of the Director rules and identifies a controller - * to handle this request. - * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, - * and call the rule handling method. - * - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method - * returns a RequestHandler object. - * - * In addition to request processing, Director will manage the session, and perform the output of - * the actual response to the browser. - * - * @uses handleRequest() rule-lookup logic is handled by this. - * @uses TestController::handleRequest() This handles the page logic for a Director::direct() call. - * @param HTTPRequest $request - * @return HTTPResponse - * @throws HTTPResponse_Exception - */ - public static function direct(HTTPRequest $request) - { - // Generate output - return static::handleRequest($request); - } - - /** - * Test a URL request, returning a response object. This method is the counterpart of - * Director::direct() that is used in functional testing. It will execute the URL given, and + * Test a URL request, returning a response object. This method is a wrapper around + * Director::handleRequest() to assist with functional testing. It will execute the URL given, and * return the result as an HTTPResponse object. * - * @uses TestController::handleRequest() Handles the page logic for a Director::direct() call. - * * @param string $url The URL to visit. * @param array $postVars The $_POST & $_FILES variables. * @param array|Session $session The {@link Session} object representing the current session. @@ -162,7 +132,7 @@ class Director implements TemplateGlobalProvider ) { return static::mockRequest( function (HTTPRequest $request) { - return static::direct($request); + return static::handleRequest($request); }, $url, $postVars, @@ -315,13 +285,24 @@ class Director implements TemplateGlobalProvider } /** - * Handle an HTTP request, defined with a HTTPRequest object. + * Process the given URL, creating the appropriate controller and executing it. + * + * Request processing is handled as follows: + * - Director::handleRequest($request) checks each of the Director rules and identifies a controller + * to handle this request. + * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, + * and call the rule handling method. + * - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method + * returns a RequestHandler object. + * + * In addition to request processing, Director will manage the session, and perform the output of + * the actual response to the browser. * - * @skipUpgrade * @param HTTPRequest $request * @return HTTPResponse + * @throws HTTPResponse_Exception */ - protected static function handleRequest(HTTPRequest $request) + public static function handleRequest(HTTPRequest $request) { $rules = Director::config()->uninherited('rules'); diff --git a/src/Control/HTTPApplication.php b/src/Control/HTTPApplication.php index ed545a34c..51b386ca1 100644 --- a/src/Control/HTTPApplication.php +++ b/src/Control/HTTPApplication.php @@ -96,7 +96,7 @@ class HTTPApplication implements Application // Ensure boot is invoked return $this->execute($request, function (HTTPRequest $request) { - return Director::direct($request); + return Director::handleRequest($request); }, $flush); } diff --git a/src/Control/HTTPRequest.php b/src/Control/HTTPRequest.php index 72dc820a9..95fd02384 100644 --- a/src/Control/HTTPRequest.php +++ b/src/Control/HTTPRequest.php @@ -846,7 +846,7 @@ class HTTPRequest implements ArrayAccess * Using GET for the "_method" override is not supported, * as GET should never carry out state changes. * Alternatively you can use a custom HTTP header 'X-HTTP-Method-Override' - * to override the original method in {@link Director::direct()}. + * to override the original method. * The '_method' POST parameter overrules the custom HTTP header. * * @param string $origMethod Original HTTP method from the browser request @@ -857,7 +857,7 @@ class HTTPRequest implements ArrayAccess { if (isset($postVars['_method'])) { if (!in_array(strtoupper($postVars['_method']), array('GET','POST','PUT','DELETE','HEAD'))) { - user_error('Director::direct(): Invalid "_method" parameter', E_USER_ERROR); + user_error('HTTPRequest::detect_method(): Invalid "_method" parameter', E_USER_ERROR); } return strtoupper($postVars['_method']); } else { diff --git a/src/Forms/Form.php b/src/Forms/Form.php index c1bb1dc8b..a7254fd98 100644 --- a/src/Forms/Form.php +++ b/src/Forms/Form.php @@ -1032,7 +1032,7 @@ class Form extends ViewableData implements HasRequestHandler * As most browsers only support GET and POST in * form submissions, all other HTTP methods are * added as a hidden field "_method" that - * gets evaluated in {@link Director::direct()}. + * gets evaluated in {@link HTTPRequest::detect_method()}. * See {@link FormMethod()} to get a HTTP method * for safe insertion into a