Class View
A view.
- ICanBoogie\View\View implements ArrayAccess, JsonSerializable uses ICanBoogie\Accessor\AccessorTrait (not available)
Methods summary
protected
get_controller( void )
: ICanBoogie\Routing\Controller
Returns
protected
lazy_get_template( void )
: string|null
Return the name of the template.
Return the name of the template.
The template name is resolved as follows:
- The
template
property of the route. - The
template
property of the controller. - The
{$controller->name}/{$controller->action}
, if the controller has anaction
property.
Returns
protected
lazy_get_layout( void )
: string
Returns the name of the layout.
Returns the name of the layout.
The layout name is resolved as follows:
- The
layout
property of the route. - The
layout
property of the controller. - If the identifier of the route starts with "admin:", "admin" is returned.
- If the route pattern is "/" and a "home" layout template is available, "home" is returned.
- If the "@page" template is available, "page" is returned.
- "default" is returned.
Returns
public
__construct( ICanBoogie\Routing\Controller $controller
, ICanBoogie\Render\Renderer $renderer
)
An event hook is attached to the action
event of the controller for late rendering,
which only happens if the response is null
.
An event hook is attached to the action
event of the controller for late rendering,
which only happens if the response is null
.
Parameters
$controller
- The controller that invoked the view.
$renderer
public
jsonSerialize( void )
Inheritdoc
template
, layout
, and variables
.Implementation of
JsonSerializable::jsonSerialize()
public
offsetGet( $offset
)
Throws
if the offset is not defined.
Inheritdoc
Implementation of
ArrayAccess::offsetGet()
protected
resolve_template( string $name
, string $prefix
, array & $tried
= [] )
: string|false
Resolve a template pathname from its name and type.
Resolve a template pathname from its name and type.
Parameters
$name
- Name of the template.
$prefix
- Template prefix.
$tried
- Reference to an array where tried paths are collected.
Returns
public
decorate_with( string $template
)
Add a template to decorate the content with.
Add a template to decorate the content with.
Parameters
$template
- Name of the template.
protected
decorate( mixed $content
)
: string
Decorate the content.
Decorate the content.
Parameters
$content
- The content to decorate.
Returns
public
partial( string $template
, array $locals
= [], array $options
= [] )
: string
Render a partial.
Render a partial.
Parameters
$template
$locals
$options
Returns
protected
on_action( ICanBoogie\Routing\Controller\ActionEvent $event
)
Renders the view on Controller::action
event.
Renders the view on Controller::action
event.
Note: The view is not rendered if the event's response is defined, which is the case when the controller obtained a result after its execution.
Parameters
$event