ICanBoogie/View v0.6.0
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • View
      • View

Classes

  • View

Interfaces

  • Exception

Traits

  • ControllerBindings
  • ViewBindings

Class View

A view.

ICanBoogie\View\View implements ArrayAccess uses ICanBoogie\PrototypeTrait (not available) ICanBoogie\View\ViewBindings
Namespace: ICanBoogie\View
Located at View.php

Methods summary

protected ICanBoogie\Routing\Controller
# get_controller( )

Returns

ICanBoogie\Routing\Controller

See

$controller
protected array
# get_variables( )

Returns

array

See

$variables
protected mixed
# get_content( )

Returns

mixed

See

$content
protected
# set_content( mixed $content )

Parameters

$content

See

$content
protected string|null
# lazy_get_template( )

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 string
# lazy_get_layout( )

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 string|false
# resolve_template( string $name, string $prefix, array & $tries = [] )

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 mixed
# decorate( mixed $content )

Decorate the content.

Decorate the content.

Parameters

$content
The content to decorate.

Returns

mixed
public string
# render( )

Render the view.

Render the view.

Returns

string
protected string
# render_with_template( mixed $content, string $template, string $type )

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 array
# prepare_engine_args( mixed $content, string $type )

Prepares engine arguments.

Prepares engine arguments.

Parameters

$content
$type

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

$event

Constants summary

integer TEMPLATE_TYPE_VIEW
# 1
integer TEMPLATE_TYPE_LAYOUT
# 2
integer TEMPLATE_TYPE_PARTIAL
# 3
string TEMPLATE_PREFIX_VIEW
# ''
string TEMPLATE_PREFIX_LAYOUT
# '@'
string TEMPLATE_PREFIX_PARTIAL
# '_'

Properties summary

Magic properties

public mixed $content

The content of the view.

public string $layout

The name of the layout that should decorate the content.

public string $template

The name of the template that should render the content.

public read-only ICanBoogie\Routing\Controller $controller

The controller invoking the view.

public read-only array $variables

The variables to pass to the template.

public read-only callable[] $layout_resolvers

@internal

public read-only callable[] $template_resolvers

@internal

Magic properties used from ICanBoogie\View\ViewBindings

$engines, $template_resolver

ICanBoogie/View v0.6.0 API documentation generated by ApiGen