class StandaloneView extends AbstractTemplateView (View source)

A standalone template view.

Helpful if you want to use Fluid separately from MVC E.g. to generate template based emails.

Properties

protected array $supportedOptions

This contains the supported options, their default values, descriptions and types.

from  AbstractTemplateView
protected array $options

The configuration options of this view

from  AbstractTemplateView
protected ControllerContext $controllerContext from  AbstractTemplateView
protected string $templateSource

Source code of the Fluid template

protected string $templatePathAndFilename

absolute path of the Fluid template

protected Environment $environment
protected ActionRequest $request
protected Bootstrap $bootstrap

Methods

static ViewInterface
createWithOptions(array $options)

Factory method to create an instance with given options.

__construct(ActionRequest $request = null, array $options = [])

Constructor

void
setTemplatePathAndFilename(string $templatePathAndFilename)

Sets the absolute path to a Fluid template file

void
setControllerContext(ControllerContext $controllerContext)

No description

bool
canRender(ControllerContext $controllerContext)

No description

string
renderSection(string $sectionName, array $variables = [], bool $ignoreUnknown = false)

Renders a given section.

void
validateOptions(array $options)

Validate options given to this view.

void
setOptions(array $options)

Merges the given options with the default values and sets the resulting options in this object.

mixed
getOption(string $optionName)

Get a specific option of this View

void
setOption(string $optionName, mixed $value)

Set a specific option of this View

void
initializeObject()

Initiates the StandaloneView by creating the required ControllerContext

setTemplate(string $templateName)

No description

void
setFormat(string $format)

Sets the format of the current request (default format is "html")

string
getFormat()

Returns the format of the current request (defaults is "html")

getRequest()

Returns the current request object

string
getTemplatePathAndFilename()

Returns the absolute path to a Fluid template file if it was specified with setTemplatePathAndFilename() before

void
setTemplateSource(string $templateSource)

Sets the Fluid template source You can use setTemplatePathAndFilename() alternatively if you only want to specify the template path

void
setTemplateRootPaths(array $templateRootPaths)

Set the root path(s) to the templates.

void
setLayoutRootPaths(array $layoutRootPaths)

Set the root path(s) to the layouts.

string
getLayoutRootPaths()

Resolves the layout root to be used inside other paths.

void
setLayoutRootPath(string $layoutRootPath)

Sets the absolute path to the folder that contains Fluid layout files

void
setPartialRootPaths(array $partialRootPaths)

Set the root path(s) to the partials.

string
getPartialRootPaths()

Returns the absolute path to the folder that contains Fluid partial files

void
setPartialRootPath(string $partialRootPath)

Sets the absolute path to the folder that contains Fluid partial files.

bool
hasTemplate()

Checks whether a template can be resolved for the current request

Details

static ViewInterface createWithOptions(array $options)

Factory method to create an instance with given options.

Parameters

array $options

Return Value

ViewInterface

__construct(ActionRequest $request = null, array $options = [])

Constructor

Parameters

ActionRequest $request

The current action request. If none is specified it will be created from the environment.

array $options

Exceptions

Exception

void setTemplatePathAndFilename(string $templatePathAndFilename)

Sets the absolute path to a Fluid template file

Parameters

string $templatePathAndFilename

Return Value

void

void setControllerContext(ControllerContext $controllerContext)

No description

Parameters

ControllerContext $controllerContext

Context of the controller associated with this view

Return Value

void

bool canRender(ControllerContext $controllerContext)

No description

Parameters

ControllerContext $controllerContext

Return Value

bool

true if the view has something useful to display, otherwise false

string renderSection(string $sectionName, array $variables = [], bool $ignoreUnknown = false)

Renders a given section.

Parameters

string $sectionName

Name of section to render

array $variables

The variables to use

bool $ignoreUnknown

Ignore an unknown section and just return an empty string

Return Value

string

rendered template for the section

Exceptions

InvalidSectionException

protected void validateOptions(array $options)

Validate options given to this view.

Parameters

array $options

Return Value

void

Exceptions

Exception

protected void setOptions(array $options)

Merges the given options with the default values and sets the resulting options in this object.

Parameters

array $options

Return Value

void

mixed getOption(string $optionName)

Get a specific option of this View

Parameters

string $optionName

Return Value

mixed

Exceptions

Exception

void setOption(string $optionName, mixed $value)

Set a specific option of this View

Parameters

string $optionName
mixed $value

Return Value

void

Exceptions

Exception

void initializeObject()

Initiates the StandaloneView by creating the required ControllerContext

Return Value

void

setTemplate(string $templateName)

No description

Parameters

string $templateName

void setFormat(string $format)

Sets the format of the current request (default format is "html")

Parameters

string $format

Return Value

void

string getFormat()

Returns the format of the current request (defaults is "html")

Return Value

string $format

ActionRequest getRequest()

Returns the current request object

Return Value

ActionRequest

string getTemplatePathAndFilename()

Returns the absolute path to a Fluid template file if it was specified with setTemplatePathAndFilename() before

Return Value

string

Fluid template path

void setTemplateSource(string $templateSource)

Sets the Fluid template source You can use setTemplatePathAndFilename() alternatively if you only want to specify the template path

Parameters

string $templateSource

Fluid template source code

Return Value

void

void setTemplateRootPaths(array $templateRootPaths)

Set the root path(s) to the templates.

Parameters

array $templateRootPaths

Root paths to the templates.

Return Value

void

void setLayoutRootPaths(array $layoutRootPaths)

Set the root path(s) to the layouts.

Parameters

array $layoutRootPaths

Root path to the layouts

Return Value

void

string getLayoutRootPaths()

Resolves the layout root to be used inside other paths.

Return Value

string

Fluid layout root path

Exceptions

InvalidTemplateResourceException

void setLayoutRootPath(string $layoutRootPath)

Sets the absolute path to the folder that contains Fluid layout files

Parameters

string $layoutRootPath

Fluid layout root path

Return Value

void

void setPartialRootPaths(array $partialRootPaths)

Set the root path(s) to the partials.

If set, overrides the one determined from $this->partialRootPathPattern

Parameters

array $partialRootPaths

Root paths to the partials. If set, overrides the one determined from $this->partialRootPathPattern

Return Value

void

string getPartialRootPaths()

Returns the absolute path to the folder that contains Fluid partial files

Return Value

string

Fluid partial root path

Exceptions

InvalidTemplateResourceException

void setPartialRootPath(string $partialRootPath)

Sets the absolute path to the folder that contains Fluid partial files.

Parameters

string $partialRootPath

Fluid partial root path

Return Value

void

bool hasTemplate()

Checks whether a template can be resolved for the current request

Return Value

bool