Class View
-
ICanBoogie\View\View
implements
ArrayAccess
uses
ICanBoogie\PrototypeTrait (not available)
ICanBoogie\View\ViewBindings
Methods summary
protected
get_controller( void )
: ICanBoogie\Routing\Controller
Returns
ICanBoogie\Routing\Controller
See
$controller
protected
get_variables( void )
: array
Returns
array
See
$variables
protected
get_content( void )
: mixed
Returns
mixed
See
$content
protected
set_content( mixed $content
)
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 an action
property.
Returns
string|null
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
string
public
__construct( ICanBoogie\Routing\Controller $controller
)
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.
public
offsetExists( $offset
)
Inheritdoc
Implementation of
ArrayAccess::offsetExists()
public
offsetGet( $offset
)
Throws
ICanBoogie\OffsetNotDefined
if the offset is not defined.
Inheritdoc
Implementation of
ArrayAccess::offsetGet()
public
offsetSet( $offset
, $value
)
Inheritdoc
Implementation of
ArrayAccess::offsetSet()
public
offsetUnset( $offset
)
Inheritdoc
Implementation of
ArrayAccess::offsetUnset()
protected
resolve_template( string $name
, string $prefix
, array & $tries
= [] )
: 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.
$tries
- Reference to an array where tried path are collected.
Returns
string|false
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
)
: mixed
Decorate the content.
Parameters
$content
- The content to decorate.
Returns
mixed
public
render( void )
: string
Render the view.
Returns
string
protected
render_with_template( mixed $content
, string $template
, string $type
)
: string
Renders the content using a template.
Renders the content using a template.
Parameters
$content
- The content to render.
$template
- Name of the template.
$type
- Type of the template.
Returns
string
protected
prepare_engine_args( mixed $content
, string $type
)
: array
Prepares engine arguments.
Prepares engine arguments.
Parameters
Returns
array
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
Constants summary
TEMPLATE_TYPE_VIEW
: integer
1
TEMPLATE_TYPE_LAYOUT
: integer
2
TEMPLATE_TYPE_PARTIAL
: integer
3
TEMPLATE_PREFIX_VIEW
: string
''
TEMPLATE_PREFIX_LAYOUT
: string
'@'
TEMPLATE_PREFIX_PARTIAL
: string
'_'
Properties summary
Magic properties
public
$layout
: string
The name of the layout that should decorate the content.
public
$template
: string
The name of the template that should render the content.
public read-only
$controller
: ICanBoogie\Routing\Controller
The controller invoking the view.
public read-only
$variables
: array
The variables to pass to the template.
public read-only
$layout_resolvers
: callable[]
public read-only
$template_resolvers
: callable[]
$engines
,
$template_resolver