\Anax\ViewViewContainer

A view container, store all views per region, render at will.

Summary

Methods
Properties
Constants
configure()
setApp()
getTemplateFile()
add()
addCallback()
addString()
hasContent()
render()
renderBuffered()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$config
$app
$views
N/A

Properties

$config

$config : array<mixed,>

Type

array<mixed,> — store the configuration in this array.

$app

$app : 

Properties

Type

$views

$views : array<mixed,>

Type

array<mixed,> — Array for all views.

Methods

configure()

configure(array<mixed,>|string  $what) : self

Read configuration from file or array, if a file, first check in ANAX_APP_PATH/config and then in ANAX_INSTALL_PATH/config.

Parameters

array<mixed,>|string $what

is an array with key/value config options or a file to be included which returns such an array.

Throws

\Anax\Common\Exception

when argument if not a filer nor an array.

Returns

self —

for chaining.

setApp()

setApp(object  $app) : $this

Inject the $app into this class.

Parameters

object $app

containing framework resources.

Returns

$this —

for chaining.

getTemplateFile()

getTemplateFile(string  $template) : string

Convert template to path to template file.

Parameters

string $template

the name of the template file to include

Throws

\Anax\View\Anax\View\Exception

when template file is missing

Returns

string —

as path to the template file

add()

add(string  $template, array  $data = array(), string  $region = "main", integer  $sort) : self

Add (create) a view to be included, pass optional data and put the view in an optional specific region (default region is "main") and pass an optional sort value where the highest value is rendered first.

The $template can be a: filename (string), callback (array with key callback set to a callable array), view array (key value array with template, data, region, sort)

Parameters

string $template

the name of the template file to include.

array $data

variables to make available to the view, default is empty.

string $region

which region to attach the view, default is "main".

integer $sort

which order to display the views.

Returns

self —

for chaining.

addCallback()

addCallback(string  $callback, array  $data = array(), string  $region = "main", integer  $sort) : $this

Add a callback to be rendered as a view.

Parameters

string $callback

function to call to get the content of the view

array $data

variables to make available to the view, default is empty

string $region

which region to attach the view

integer $sort

which order to display the views

Returns

$this

addString()

addString(string  $content, string  $region = "main", integer  $sort) : $this

Add a string as a view.

Parameters

string $content

the content

string $region

which region to attach the view

integer $sort

which order to display the views

Returns

$this

hasContent()

hasContent(string  $region) : $this

Check if a region has views to render.

Parameters

string $region

which region to check

Returns

$this

render()

render(string  $region = "main") : void

Render all views for a specific region.

Parameters

string $region

which region to use

renderBuffered()

renderBuffered(string  $region = "main") : string

Render all views for a specific region and buffer the result.

Parameters

string $region

which region to use.

Returns

string —

with the buffered results.