__construct()
__get()
__isset()
__set()
__toString()
__unset()
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
$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 |
---|---|
category | Core |
link | http://docs.fuelphp.com/classes/view.html |
__construct(string $file, object $data, bool $filter)
$view = new View($file);
uses | \Fuel\Core\View::set_filename |
---|
string
view filename
object
array of values
bool
__get(string $key) : mixed
Local variables will be returned before global variables.
$value = $view->foo;
string
variable name
\OutOfBoundsException |
---|
mixed
__isset(string $key) : boolean
isset($view->foo);
[!!] null
variables are not considered to be set by isset.
string
variable name
boolean
__set(string $key, mixed $value) : void
$view->foo = 'something';
string
variable name
mixed
value
__toString() : string
uses | \Fuel\Core\View::render |
---|
string
__unset(string $key) : void
unset($view->foo);
string
variable name
auto_filter(bool $filter) : \Fuel\Core\View
$view->auto_filter(false);
bool
whether to auto filter or not
bind(string $key, mixed $value, bool $filter) : \Fuel\Core\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);
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);
string
variable name
mixed
referenced variable
bool
whether to filter the data or not
forge(string $file, object $data, bool $auto_filter) : \Fuel\Core\View
If you do not define the "file" parameter, you must call [static::set_filename].
$view = View::forge($file);
string
view filename
object
array of values
bool
get(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.
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 |
---|
\Fuel\Core\$file
string view filename
\FuelException |
---|
string
set(string $key, mixed $value, bool $filter) : \Fuel\Core\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'));
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);
string
view filename
\FuelException |
---|
set_global(string $key, mixed $value, bool $filter) : void
View::set_global($name, $value);
string
variable name or an array of variables
mixed
value
bool
whether to filter the data or not
set_safe(string $key, mixed $value) : \Fuel\Core\View
$view->set_safe('foo', 'bar');
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();
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();
bool
File override
string
unsanitize($var) : mixed
mixed
mixed
$active_language : string
$auto_filter : bool
$data : array
$extension : string
$file_name : string
$filter_closures : bool
$global_data : array
$global_filter : array
$local_filter : array
$request_paths : array