Class

eZ\Publish\Core\MVC\Symfony\View\ContentView

class ContentView extends BaseView implements View, ContentValueView, LocationValueView, EmbedView, CachableView

Main object to be rendered by the View Manager when viewing a content.

Holds the path to the template to be rendered by the view manager and the parameters to inject in it.

The template path can be a closure. In that case, the view manager will invoke it instead of loading a template. $parameters will be passed to the callable in addition to the Content or Location object (depending on the context). The prototype of the closure must be : namespace Foo; use eZ\Publish\API\Repository\Values\Content\ContentInfo; use eZ\Publish\API\Repository\Values\Content\Location;

// For a content function ( ContentInfo $contentInfo, array $parameters = array() ) { // Do something to render // Must return a string to display }

// For a location function ( Location $location, array $parameters = array() ) { // Do something to render // Must return a string to display }

Methods

__construct($templateIdentifier = null, array $parameters = array(), $viewType = 'full')

from BaseView
setParameters(array $parameters)

from BaseView
addParameters(array $parameters)

Adds a hash of parameters to the existing parameters.

from BaseView
array getParameters()

from BaseView
bool hasParameter(string $parameterName)

Checks if $parameterName exists.

from BaseView
mixed getParameter(string $parameterName)

Returns parameter value by $parameterName.

from BaseView
setTemplateIdentifier(string|Closure $templateIdentifier)

from BaseView
string|Closure getTemplateIdentifier()

from BaseView
setConfigHash(array $config)

Injects the config hash that was used to match and generate the current view.

from BaseView
array|null getConfigHash()

Returns the config hash.

from BaseView
setViewType($viewType)

from BaseView
getViewType()

from BaseView
setControllerReference(ControllerReference $controllerReference)

from BaseView
ControllerReference getControllerReference()

from BaseView
setResponse(Response $response)

Sets a pre-configured Response that will be used to render the View.

from BaseView
Response|null getResponse()

Returns the pre-configured Response.

from BaseView
setCacheEnabled($cacheEnabled)

from BaseView
isCacheEnabled()

from BaseView
setContent(Content $content)

Content getContent()

Returns the Content.

setLocation(Location $location)

Location getLocation()

setIsEmbed(bool $value)

Sets the value as embed / not embed.

bool isEmbed()

Is the view an embed or not.

Details

in BaseView at line 49
public __construct($templateIdentifier = null, array $parameters = array(), $viewType = 'full')

Parameters

$templateIdentifier
array $parameters
$viewType

Exceptions

InvalidArgumentType

in BaseView at line 62
public setParameters(array $parameters)

Parameters

array $parameters Hash of parameters to pass to the template/closure

in BaseView at line 72
public addParameters(array $parameters)

Adds a hash of parameters to the existing parameters.

Parameters

array $parameters

in BaseView at line 80
public array getParameters()

Return Value

array

in BaseView at line 92
public bool hasParameter(string $parameterName)

Checks if $parameterName exists.

Parameters

string $parameterName

Return Value

bool

in BaseView at line 107
public mixed getParameter(string $parameterName)

Returns parameter value by $parameterName.

Throws an \InvalidArgumentException if $parameterName is not set.

Parameters

string $parameterName

Return Value

mixed

Exceptions

InvalidArgumentException

in BaseView at line 121
public setTemplateIdentifier(string|Closure $templateIdentifier)

Parameters

string|Closure $templateIdentifier

Exceptions

InvalidArgumentType

in BaseView at line 133
public string|Closure getTemplateIdentifier()

Return Value

string|Closure

in BaseView at line 147
public setConfigHash(array $config)

Injects the config hash that was used to match and generate the current view.

Typically, the hash would have as keys: - template : The template that has been matched - match : The matching configuration, including the matcher "identifier" and what has been passed to it. - matcher : The matcher object.

Parameters

array $config

in BaseView at line 157
public array|null getConfigHash()

Returns the config hash.

Return Value

array|null

in BaseView at line 162
public setViewType($viewType)

Parameters

$viewType

in BaseView at line 167
public getViewType()

in BaseView at line 172
public setControllerReference(ControllerReference $controllerReference)

Parameters

ControllerReference $controllerReference

in BaseView at line 180
public ControllerReference getControllerReference()

Return Value

ControllerReference

in BaseView at line 195
public setResponse(Response $response)

Sets a pre-configured Response that will be used to render the View.

Parameters

Response $response

in BaseView at line 200
public Response|null getResponse()

Returns the pre-configured Response.

Return Value

Response|null

in BaseView at line 205
public setCacheEnabled($cacheEnabled)

Parameters

$cacheEnabled

in BaseView at line 210
public isCacheEnabled()

at line 55
public setContent(Content $content)

Parameters

Content $content

at line 65
public Content getContent()

Returns the Content.

Return Value

Content

at line 73
public setLocation(Location $location)

Parameters

Location $location

at line 81
public Location getLocation()

Return Value

Location

at line 101
public setIsEmbed(bool $value)

Sets the value as embed / not embed.

Parameters

bool $value

at line 110
public bool isEmbed()

Is the view an embed or not.

Return Value

bool True if the view is an embed, false if it is not.