ICanBoogie/View master
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • View
      • View

Classes

  • View

Interfaces

  • Exception

Traits

  • ControllerBindings

Class View

A view.

ICanBoogie\View\View implements ArrayAccess, JsonSerializable uses ICanBoogie\Accessor\AccessorTrait (not available)
Namespace: ICanBoogie\View
Located at View.php

Methods summary

protected ICanBoogie\Routing\Controller
# get_controller( )

Returns

ICanBoogie\Routing\Controller
protected ICanBoogie\Render\Renderer
# get_renderer( )

Returns

ICanBoogie\Render\Renderer
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, 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( )

Inheritdoc

Returns an array with the following keys: template, layout, and variables.

Implementation of

JsonSerializable::jsonSerialize()
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()
public ICanBoogie\View\View
# assign( array $variables )

Assign multiple variables.

Assign multiple variables.

Parameters

$variables

Returns

ICanBoogie\View\View
$this
protected string|false
# resolve_template( string $name, string $prefix, array & $tried = [] )

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

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

Decorate the content.

Decorate the content.

Parameters

$content
The content to decorate.

Returns

string
public string
# render( )

Render the view.

Render the view.

Returns

string
public string
# partial( string $template, array $locals = [], array $options = [] )

Render a partial.

Render a partial.

Parameters

$template
$locals
$options

Returns

string
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 ICanBoogie\Render\Renderer $renderer

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

ICanBoogie/View master API documentation generated by ApiGen