ViewModel

package Fuel
subpackage Core
category Core
author Jelmer Schreuder

 Methods

Fetches an existing value from the template

__get($name) : mixed

Parameters

$name

Returns

mixed

Magic method, determines if a variable is set.

__isset(string $key) : boolean

isset($view->foo);

Parameters

$key

string

variable name

Returns

boolean

Sets and sanitizes a variable on the template

__set($key, $value) 

Parameters

$key

string

$value

mixed

Auto-render on toString

__toString() 

Executed after the view method

after() 

Change auto filter setting

auto_filter(null | bool $setting) : void | bool

Parameters

$setting

nullbool

change setting (bool) or get the current setting (null)

Returns

voidboolreturns current setting or nothing when it is changed

Executed before the view method

before() 

Assigns a value by reference.

bind(string $key, mixed $value, bool $filter) : \Fuel\Core\ViewModel

The benefit of binding is that values can be altered without re-setting them. It is also possible to bind variables before they have values. Assigned values will be available as a variable within the view file:

$this->bind('ref', $bar);

fluent This method is part of a fluent interface and will return the same instance

Parameters

$key

string

variable name

$value

mixed

referenced variable

$filter

bool

Whether to filter the var on output

Returns

Factory for fetching the ViewModel

forge(string $viewmodel, string $method, $auto_filter, $view) : \Fuel\Core\ViewModel

Parameters

$viewmodel

string

ViewModel classname without View_ prefix or full classname

$method

string

Method to execute

$auto_filter

$view

Returns

Gets a variable from the template

get($key, $default) 

Parameters

$key

string

$default

Returns the View object associated with this Viewmodel

get_view() : \Fuel\Core\View

Returns

Add variables through method and after() and create template as a string

render() 

Sets a variable on the template

set($key, $value, $filter) 

Parameters

$key

string

$value

mixed

$filter

bool|null

The default view method Should set all expected variables upon itself

view() 

__construct()

__construct($method, $auto_filter, $view) 

Parameters

$method

$auto_filter

$view

Returns the active request object.

request() : \Fuel\Core\Request

Construct the View object

set_view() 

 Properties

 

<p>active request during ViewModel creation for proper context</p>

$_active_request : \Fuel\Core\Request

 

<p>whether or not to use auto filtering</p>

$_auto_filter : bool

 

<p>method to execute when rendering</p>

$_method : string

 

<p>view name, after instantiation a View object</p>

$_view : string | \Fuel\Core\View