__construct()
__get()
__isset()
__set()
__toString()
__unset()
_init()
auto_filter()
bind()
bind_global()
forge()
get()
render()
set()
set_filename()
set_global()
set_safe()
get_data()
process_file()
unsanitize()
$active_language
$active_request
$auto_filter
$data
$extension
$file_name
$filter_closures
$global_data
$global_filter
$loaded_files
$local_filter
$request_paths
View class
Acts as an object wrapper for HTML pages with embedded PHP, called "views". Variables can be assigned with the view object and referenced locally within the view.
package | Fuel |
---|
__construct(string $file, object $data, bool $filter)
$view = new View($file);
uses | \Fuel\Core\View::set_filename |
---|---|
inherited_from | \Fuel\Core\View::__construct() |
string
view filename
object
array of values
bool
__get(string $key) : mixed
Local variables will be returned before global variables.
$value = $view->foo;
inherited_from | \Fuel\Core\View::__get() |
---|
string
variable name
\OutOfBoundsException |
---|
mixed
__isset(string $key) : boolean
isset($view->foo);
[!!] null
variables are not considered to be set by isset.
inherited_from | \Fuel\Core\View::__isset() |
---|
string
variable name
boolean
__set(string $key, mixed $value) : void
$view->foo = 'something';
inherited_from | \Fuel\Core\View::__set() |
---|
string
variable name
mixed
value
__toString() : string
uses | \Fuel\Core\View::render |
---|---|
inherited_from | \Fuel\Core\View::__toString() |
string
__unset(string $key) : void
unset($view->foo);
inherited_from | \Fuel\Core\View::__unset() |
---|
string
variable name
_init()
auto_filter(bool $filter) : \Fuel\Core\View
$view->auto_filter(false);
inherited_from | \Fuel\Core\View::auto_filter() |
---|
bool
whether to auto filter or not
bind(string $key, mixed $value, bool $filter) : \Parser\View
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 reference can be accessed as $ref within the view
$view->bind('ref', $bar);
inherited_from | \Fuel\Core\View::bind() |
---|---|
fluent | This method is part of a fluent interface and will return the same instance |
string
variable name
mixed
referenced variable
bool
Whether to filter the var on output
bind_global(string $key, mixed $value, bool $filter) : void
View::bind_global($key, $value);
inherited_from | \Fuel\Core\View::bind_global() |
---|
string
variable name
mixed
referenced variable
bool
whether to filter the data or not
forge(string $file, array $data, bool $auto_encode) : object
If you do not define the "file" parameter, you must call [static::set_filename].
$view = View::forge($file);
string
view filename
array
view data
bool
auto encode boolean, null for default
object
a new view instanceget(string $key, mixed $default) : mixed
Local variables will be returned before global variables.
$value = $view->get('foo', 'bar');
If the key is not given or null, the entire data array is returned.
If a default parameter is not given and the variable does not exist, it will throw an OutOfBoundsException.
inherited_from | \Fuel\Core\View::get() |
---|
string
The variable name
mixed
The default value to return
\OutOfBoundsException |
---|
mixed
render(\Fuel\Core\$file $file) : string
Global and local data are merged and extracted to create local variables within the view file.
$output = $view->render();
[!!] Global variables with the same key name as local variables will be overwritten by the local variable.
uses | \Fuel\Core\static::capture |
---|---|
inherited_from | \Fuel\Core\View::render() |
\Fuel\Core\$file
string view filename
\FuelException |
---|
string
set(string $key, mixed $value, bool $filter) : \Parser\View
Assigned values will be available as a variable within the view file:
// This value can be accessed as $foo within the view
$view->set('foo', 'my value');
You can also use an array to set several values at once:
// Create the values $food and $beverage in the view
$view->set(array('food' => 'bread', 'beverage' => 'water'));
inherited_from | \Fuel\Core\View::set() |
---|---|
fluent | This method is part of a fluent interface and will return the same instance |
string
variable name or an array of variables
mixed
value
bool
whether to filter the data or not
set_filename(string $file, $reverse) : \Fuel\Core\View
$view->set_filename($file);
inherited_from | \Fuel\Core\View::set_filename() |
---|
string
view filename
\FuelException |
---|
set_global(string $key, mixed $value, bool $filter) : void
View::set_global($name, $value);
inherited_from | \Fuel\Core\View::set_global() |
---|
string
variable name or an array of variables
mixed
value
bool
whether to filter the data or not
set_safe(string $key, mixed $value) : \Parser\View
$view->set_safe('foo', 'bar');
inherited_from | \Fuel\Core\View::set_safe() |
---|---|
fluent | This method is part of a fluent interface and will return the same instance |
string
variable name or an array of variables
mixed
value
get_data(string $scope) : array
It filters the data if necessary.
$data = $this->get_data();
inherited_from | \Fuel\Core\View::get_data() |
---|
string
local/glocal/all
array
view dataprocess_file(bool $file_override) : string
The view data will be extracted to make local variables.
$output = $this->process_file();
inherited_from | \Fuel\Core\View::process_file() |
---|
bool
File override
string
unsanitize($var) : mixed
inherited_from | \Fuel\Core\View::unsanitize() |
---|
mixed
mixed
$active_language : string
inherited_from | \Fuel\Core\View::$$active_language |
---|
$active_request : \Fuel\Core\Request
inherited_from | \Fuel\Core\View::$$active_request |
---|
$auto_filter : bool
inherited_from | \Fuel\Core\View::$$auto_filter |
---|
$data : array
inherited_from | \Fuel\Core\View::$$data |
---|
$extension : string
inherited_from | \Fuel\Core\View::$$extension |
---|
$file_name : string
inherited_from | \Fuel\Core\View::$$file_name |
---|
$filter_closures : bool
inherited_from | \Fuel\Core\View::$$filter_closures |
---|
$global_data : array
inherited_from | \Fuel\Core\View::$$global_data |
---|
$global_filter : array
inherited_from | \Fuel\Core\View::$$global_filter |
---|
$loaded_files : array
$local_filter : array
inherited_from | \Fuel\Core\View::$$local_filter |
---|
$request_paths : array
inherited_from | \Fuel\Core\View::$$request_paths |
---|