Class to manage most of the flow of a request to a XenForo page.

This class: resolves a URL to a route, loads a specified controller, executes an action in that controller, loads the view, renders the view, and outputs the response.

Most dependent objects can be injected

package XenForo_Mvc

 Methods

Constructor.

__construct(\XenForo_Dependencies_Abstract $dependencies) 

Sets up dependencies.

Parameters

$dependencies

XenForo_Dependencies_Abstract

Executes the controller dispatch loop.

dispatch(\XenForo_RouteMatch $routeMatch) : \XenForo_ControllerResponse_Abstract | null

Parameters

$routeMatch

\XenForo_RouteMatch

Returns

\XenForo_ControllerResponse_AbstractnullNull will only occur if error handling is broken

getDependencies()

getDependencies() : \XenForo_Dependencies_Abstract

getRequest()

getRequest() : \Zend_Controller_Request_Http

Returns

\Zend_Controller_Request_Http

getResponse()

getResponse() : \Zend_Controller_Response_Http

Returns

\Zend_Controller_Response_Http

Renders page-level debugging output and replaces the original view content with it.

renderDebugOutput(string $originalContent) : string

Alternatively, it could inject itself into the view content.

Parameters

$originalContent

string

Original, rendered view content

Returns

stringReplacement rendered view content

Renders the view.

renderView(\XenForo_ControllerResponse_Abstract $controllerResponse, \XenForo_ViewRenderer_Abstract $viewRenderer, array $containerParams) : string

Parameters

$controllerResponse

\XenForo_ControllerResponse_Abstract

Controller response object from last controller

$viewRenderer

\XenForo_ViewRenderer_Abstract

View renderer for specified response type

$containerParams

array

Extra container params (probably "sections" from routing)

Returns

stringView output

Sends the request to the router for routing.

route() : \XenForo_RouteMatch

Runs the request, handling from routing straight through to response output.

run() : string | null

Primary method to be used by the external API.

Returns

stringnullReturns a string if {@link $_sendResponse} is false

Setter for {@link $_request}.

setRequest(\Zend_Controller_Request_Http $request) 

Parameters

$request

Zend_Controller_Request_Http

Sets the request paths for this request.

setRequestPaths() 

Setter for {@link $_response}.

setResponse(\Zend_Controller_Response_Http $response) 

Parameters

$response

Zend_Controller_Response_Http

Setter for {@link $_sendResponse}.

setSendResponse($sendResponse) 

Parameters

$sendResponse

boolean

Sets up the default version of objects needed to run.

setup() 

Determines if the full debug output show be shown.

showDebugOutput() : boolean

This usually depends on application configuration and a request param.

Returns

boolean

Called when a printable exception occurs, to get the controller response object.

_getErrorResponseFromException(\Exception $e) : \XenForo_ControllerResponse_Abstract

Parameters

$e

\Exception

Exception that occurred

Returns

Loads the controller only if it and the specified action have been validated as callable.

_getValidatedController(string $controllerName, string $action, \XenForo_RouteMatch $routeMatch) : \XenForo_Controller | null

Parameters

$controllerName

string

Name of the controller to load

$action

string

Name of the action to run

$routeMatch

\XenForo_RouteMatch

Route match for this request (may not match controller)

Returns

Gets the view renderer for the specified response type.

_getViewRenderer(string $responseType) : \XenForo_ViewRenderer_Abstract

Parameters

$responseType

string

Response type (eg, html, xml, json)

Returns

Handles a controller response to determine if something failed or a reroute is needed.

_handleControllerResponse(mixed $controllerResponse, string $controllerName, string $action) : false | array

Parameters

$controllerResponse

mixed

Exceptions will be thrown if is not {@link XenForo_ControllerResponse_Abstract}

$controllerName

string

Name of the controller that generated this response

$action

string

Name of the action that generated this response

Returns

falsearrayFalse if no reroute is needed. Array with keys controllerName and action if needed.

Returns information about how to reroute if a page not found error occurs.

_rerouteNotFound(string $controllerName, string $action) : array

Parameters

$controllerName

string

Controller name

$action

string

Action

Returns

arrayReroute array

Returns information about how to reroute if a server error occurs.

_rerouteServerError(\Exception $e) : array

Parameters

$e

\Exception

Exception object that triggered the error

Returns

arrayReroute array

 Properties

 

An object that is able to load the dependencies needed to use this front controller.

$_dependencies : \XenForo_Dependencies_Abstract

 

Request object.

$_request : \Zend_Controller_Request_Http

see \global\setRequest()
 

Response object.

$_response : \Zend_Controller_Response_Http

see \global\setResponse()
 

Controls whether calling {@link run()} prints the response via the {@link $_response} object.

$_sendResponse : boolean

If set to false, the response is returned instead.

see \global\setSendResponse()