Abstract handler for view rendering of a particular response type.

Handles rendering of different types of controller responses.

package XenForo_Mvc

 Methods

Constructor.

__construct(\XenForo_Dependencies_Abstract $dependencies, \Zend_Controller_Response_Http $response, \Zend_Controller_Request_Http $request) 

Parameters

$response

\Zend_Controller_Response_Http

$request

\Zend_Controller_Request_Http

Helper method to create a template object for rendering.

createTemplateObject(string $templateName, array $params) : \XenForo_Template_Abstract

Templates only represent HTML output, so no response type is needed. However, they can be used in any response type.

Parameters

$templateName

string

Name of the template to create

$params

array

Key-value parameters to pass to the template

Returns

Gets the dependencies handler object.

getDependencyHandler() : \XenForo_Dependencies_Abstract

Gets the 'needs container' setting.

getNeedsContainer() : boolean

Returns

boolean

Preloads a template with the template handler for use later.

preloadTemplate(string $templateName) 

Parameters

$templateName

string

Template name

Renders the container output for a page.

renderContainer(string $contents, array $params) : string

This often represents the "chrome" of a page, including aspects like the header and footer. The content from the other render methods will generally be put inside this.

Note that not all response types will have a container. In which case, they should return the inner contents directly.

Parameters

$contents

string

Contents from a previous render method

$params

array

Key-value pairs to manipulate the container

Returns

stringRendered output

Renders output of an error.

renderError(string $errorText) : string | false

Parameters

$errorText

string

Text of the error to render

Returns

stringfalseRendered output. False if rendering wasn't possible (see {@link renderUnrepresentable()}).

Renders output of an message.

renderMessage(string $message) : string | false

Parameters

$message

string

Text of the message to render

Returns

stringfalseRendered output. False if rendering wasn't possible (see {@link renderUnrepresentable()}).

Renders a redirect.

renderRedirect(integer $redirectType, string $redirectTarget, mixed $redirectMessage, array $redirectParams) : string

Most renderers will actually redirect, but some may not.

Parameters

$redirectType

integer

Type of redirect. See {@link XenForo_ControllerResponse_Redirect}

$redirectTarget

string

Target to redirect to

$redirectMessage

mixed

Redirect message (unused by some redirect methods)

$redirectParams

array

Extra redirect parameters (unused by HTML)

Returns

stringEmpty string (nothing to display)

Renders a sub or child view.

renderSubView(\XenForo_ControllerResponse_View $subView) : string | \XenForo_Template_Abstract | false

Parameters

Returns

Fallback for rendering an "unrepresentable" message.

renderUnrepresentable() : string

Method is called when the concrete rendering function returns false or no concrete rendering function is available.

Returns

stringRendered output

Renders output of a view.

renderView(string $viewName, array $params, string $templateName, \XenForo_ControllerResponse_View $subView) : string | \XenForo_Template_Abstract | false

Should instantiate the view object and render it. Note that depending on response type, this class may have to manipulate the view name or instantiate a different object.

Parameters

$viewName

string

Name of the view to create

$params

array

Key-value array of parameters for the view.

$templateName

string

Name of the template that will be used to display (may be ignored by view)

$subView

\XenForo_ControllerResponse_Viewnull

A sub-view that will be rendered internal to this view

Returns

string\XenForo_Template_AbstractfalseRendered output. False if rendering wasn't possible (see {@link renderUnrepresentable()}).

General helper method to create and render a view object for the specified response type.

renderViewObject(string $class, string $responseType, array $params, string $templateName) : string | false | null

Returns null if no class can be loaded or no view method has been defined. Otherwise, the return is defined by the view render method, which should return either a string (rendered content) or false (unrepresentable).

Parameters

$class

string

View class name

$responseType

string

Response type (translated to method name as render$type)

$params

array

Key-value parameters to pass to view. May be modified by the prepareParams call within.

$templateName

string

Template name to pass to view (may be ignored by view)

Returns

stringfalsenull

Replaces the place holders for required externals with the actual requirements.

replaceRequiredExternalPlaceholders(\XenForo_Template_Abstract $template, string $rendered) : string

This approach is needed to ensure that all requirements are properly included, even if they are included after the comment has been rendered.

Parameters

$template

\XenForo_Template_Abstract

The container template object; used to get the requirements

$rendered

string

Already rendered output

Returns

string

Sets the 'needs container' setting

setNeedsContainer(boolean $required) : boolean

Parameters

$required

boolean

Returns

boolean

Data that should be preloaded for the container.

_preloadContainerData() 

Templates/phrases may be accidentally (or intentionally) rendered in the view or before the container is set to be rendered. Preloading data here can allow all the data to be fetched at once.

 Properties

 

$_dependencies : \XenForo_Dependencies_Abstract
 

$_needsContainer : boolean

This may apply to an entire renderer or just individual render types.

 

$_request : \Zend_Controller_Request_Http

Can be used to manipulate output based in input parameters AT YOUR OWN RISK. Strictly, making use of this breaks MVC principles, so avoid it if you can.

 

$_response : \Zend_Controller_Response_Http

Generally should only be used to manipulate response codes if needed.