\Charcoal\ViewViewableTrait

Implementation, as trait, of the {@see \Charcoal\View\ViewableInterface}.

Summary

Methods
Properties
Constants
__toString()
setTemplateIdent()
templateIdent()
setView()
view()
render()
renderTemplate()
setViewController()
viewController()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$templateIdent
$viewController
$view
N/A

Properties

$templateIdent

$templateIdent : string

The object's template identifier.

Type

string

$viewController

$viewController : \Charcoal\View\ViewableInterface

The context for the {@see self::$view} to render templates.

Type

\Charcoal\View\ViewableInterface

Methods

__toString()

__toString() : string

Render the viewable object.

Returns

string

setTemplateIdent()

setTemplateIdent(string  $templateIdent) : \Charcoal\View\ViewableInterface

Set the template identifier for this viewable object.

Usually, a path to a file containing the template to be rendered at runtime.

Parameters

string $templateIdent

The template ID.

Throws

\InvalidArgumentException

If the template identifier is not a string.

Returns

\Charcoal\View\ViewableInterface

Chainable

templateIdent()

templateIdent() : string

Retrieve the template identifier for this viewable object.

Returns

string

setView()

setView(\Charcoal\View\ViewInterface|array  $view) : \Charcoal\View\ViewableInterface

Set the renderable view.

Parameters

\Charcoal\View\ViewInterface|array $view

The view instance to use to render.

Throws

\InvalidArgumentException

If the view parameter is not an array or a View object.

Returns

\Charcoal\View\ViewableInterface

Chainable

view()

view() : \Charcoal\View\ViewInterface

Retrieve the renderable view.

Returns

\Charcoal\View\ViewInterface

The object's View instance.

render()

render(string  $templateIdent = null) : string

Render the template by the given identifier.

Usually, a path to a file containing the template to be rendered at runtime.

Parameters

string $templateIdent

The template to load, parse, and render. If NULL, will use the object's previously set template identifier.

Returns

string —

The rendered template.

renderTemplate()

renderTemplate(string  $templateString) : string

Render the given template from string.

Parameters

string $templateString

The template to render from string.

Returns

string —

The rendered template.

setViewController()

setViewController(\Charcoal\View\ViewableInterface|object|array|null  $controller) : \Charcoal\View\ViewableInterface

Set a view controller for the template's context.

Parameters

\Charcoal\View\ViewableInterface|object|array|null $controller

A view controller to use when rendering.

Throws

\InvalidArgumentException

If the controller is invalid.

Returns

\Charcoal\View\ViewableInterface

Chainable

viewController()

viewController() : \Charcoal\View\ViewableInterface

Retrieve a view controller for the template's context.

If no controller has been defined, it will return itself.

Returns

\Charcoal\View\ViewableInterface