ICanBoogie
  • Documentation
  • API Reference
  • View 0.9.x
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 get_controller( void ) : ICanBoogie\Routing\Controller

Returns

ICanBoogie\Routing\Controller
protected get_renderer( void ) : ICanBoogie\Render\Renderer

Returns

ICanBoogie\Render\Renderer
protected get_variables( void ) : array

Returns

array

See

$variables
protected get_content( void ) : mixed

Returns

mixed

See

$content
protected set_content( mixed $content )

Parameters

$content

See

$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, 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

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

Assign multiple variables.

Assign multiple variables.

Parameters

$variables

Returns

ICanBoogie\View\View
$this
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

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 ) : string

Decorate the content.

Decorate the content.

Parameters

$content
The content to decorate.

Returns

string
public render( void ) : string

Render the view.

Render the view.

Returns

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

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

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 $content : mixed

The content of the view.

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

The controller invoking the view.

public read-only $variables : array

The variables to pass to the template.

public read-only $layout_resolvers : callable[]

@internal

public read-only $template_resolvers : callable[]

@internal

View 0.9.x – Check on GitHub – API documentation generated by ApiGen