Documentation

BaseView
in package

AbstractYes

Loads and displays Kohana view files.

Table of Contents

Properties

$DEBUG_COMMENT  : mixed
$EXTENSION  : mixed
$kohana_filename  : mixed
$kohana_global_data  : array<string, mixed>
$kohana_local_data  : array<string, mixed>

Methods

__construct()  : mixed
Attempts to load a view and pre-load view data.
__get()  : mixed
Magically gets a view variable.
__isset()  : bool
Magic method access to test for view property
__set()  : void
Magically sets a view variable.
__toString()  : string
Magically converts view object to string.
bind()  : object
Sets a bound variable by reference.
create()  : BaseView
Create a view as appropriate for the 'sprout.skin_views_type' config.
exists()  : bool
Does this template exist?
getDebugComment()  : string
A debug comment indicates where this view is being loaded.
getSkinType()  : string
The View class to use for the current skin.
include()  : string
Shorthand load and render a view.
isPropertySet()  : bool|array<string|int, mixed>
Checks for a property existence in the view locally or globally. Unlike the built in __isset(), this method can take an array of properties to test simultaneously.
render()  : ($print is true ? void : string)
Renders a view.
set()  : object
Sets a view variable.
setFilename()  : object
Sets the view filename.
setGlobal()  : void
Sets a view global variable.
skin()  : BaseView
Same as create() but enforces that only skin templates will be loaded.

Properties

$DEBUG_COMMENT

public static mixed $DEBUG_COMMENT = !IN_PRODUCTION

$EXTENSION

protected static mixed $EXTENSION = '.html'

$kohana_filename

protected mixed $kohana_filename = FALSE

$kohana_global_data

protected static array<string, mixed> $kohana_global_data = []

$kohana_local_data

protected array<string, mixed> $kohana_local_data = []

Methods

__construct()

Attempts to load a view and pre-load view data.

public __construct(string $name[, array<string|int, mixed> $data = [] ]) : mixed
Parameters
$name : string

view name

$data : array<string|int, mixed> = []

pre-load data

Tags
throws
Kohana_Exception

if the requested view cannot be found

__get()

Magically gets a view variable.

public & __get(string $key) : mixed
Parameters
$key : string

variable key

Return values
mixed —

variable value if the key is found or void if the key is not found

__isset()

Magic method access to test for view property

public __isset([string $key = null ]) : bool
Parameters
$key : string = null

View property to test for

Return values
bool

__set()

Magically sets a view variable.

public __set(string $key, mixed $value) : void
Parameters
$key : string

variable key

$value : mixed

variable value

__toString()

Magically converts view object to string.

public __toString() : string
Return values
string

bind()

Sets a bound variable by reference.

public bind(string $name, mixed &$var) : object
Parameters
$name : string

name of variable

$var : mixed

variable to assign by reference

Return values
object

create()

Create a view as appropriate for the 'sprout.skin_views_type' config.

public static create(string $name[, array<string|int, mixed> $data = [] ]) : BaseView

This is important when rendering something from a skin. Because newer skins will be Twig, whereas older skins will be PHP. Modules that render out to a skin will want to use this so that they remain compatible with either skin format.

Beware though, internal sprout/ or modules/ templates will typically be PHP or Twig, not both. In this case, use new TwigView() or new PhpView() appropriately.

Parameters
$name : string
$data : array<string|int, mixed> = []
Tags
throws
Exception

An invalid template path

Return values
BaseView

exists()

Does this template exist?

public static exists(string $name) : bool

This abides by dynamic-skin loading rules for different view types. So if the skin is set to 'twig' it'll search for 'skin/etc/view.twig'.

Parameters
$name : string
Tags
throws
Kohana_Exception
Exception
Return values
bool

getDebugComment()

A debug comment indicates where this view is being loaded.

public getDebugComment() : string

This is injected into the rendered output. It's only enabled given the static DEBUG_COMMENT property - default matches IN_PRODUCTION.

This only appears in HTML/XML output.

Return values
string

getSkinType()

The View class to use for the current skin.

public static getSkinType() : string
Return values
string —

a class name

include()

Shorthand load and render a view.

public static include(string $name[, null|array<string|int, mixed> $data = [] ]) : string
Parameters
$name : string
$data : null|array<string|int, mixed> = []
Tags
throws
Exception
Return values
string

isPropertySet()

Checks for a property existence in the view locally or globally. Unlike the built in __isset(), this method can take an array of properties to test simultaneously.

public isPropertySet([array<string|int, mixed>|string|false $key = false ]) : bool|array<string|int, mixed>
Parameters
$key : array<string|int, mixed>|string|false = false

property name to test for or array of property names to test for

Return values
bool|array<string|int, mixed> —

property test result or associative array of keys and boolean test result

render()

Renders a view.

public abstract render([bool $print = false ][, string|false $renderer = false ]) : ($print is true ? void : string)
Parameters
$print : bool = false

set to TRUE to echo the output instead of returning it

$renderer : string|false = false

Special renderer callback to pass the output through

Return values
($print is true ? void : string) —

Return the view as a string, or null if print is FALSE

set()

Sets a view variable.

public set(string|array<string|int, mixed> $name[, mixed $value = null ]) : object
Parameters
$name : string|array<string|int, mixed>

name of variable or an array of variables

$value : mixed = null

value when using a named variable

Return values
object

setFilename()

Sets the view filename.

public setFilename(string $name) : object
Parameters
$name : string

The view filename

Tags
chainable
Return values
object

setGlobal()

Sets a view global variable.

public static setGlobal(string|array<string|int, mixed> $name[, mixed $value = null ]) : void
Parameters
$name : string|array<string|int, mixed>

name of variable or an array of variables

$value : mixed = null

value when using a named variable

skin()

Same as create() but enforces that only skin templates will be loaded.

public static skin(string $name[, array<string|int, mixed> $data = [] ]) : BaseView

This can be particularly useful because most (all) modules and core templates do not offer both a PHP and a Twig template, so performing skin-dynamic loading is somewhat pointless.

Use this if you're unsure. Perhaps the name 'skin()' will make it's behaviour more obvious.

Parameters
$name : string
$data : array<string|int, mixed> = []
Tags
throws
Exception

An invalid skin path

Return values
BaseView
On this page

Search results