__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 |
|---|
stringview filename
objectarray of values
bool
__get(string $key) : mixed
Local variables will be returned before global variables.
$value = $view->foo;
stringvariable name
\OutOfBoundsException |
|---|
mixed__isset(string $key) : boolean
isset($view->foo);
[!!] null variables are not considered to be set by isset.
stringvariable name
boolean__set(string $key, mixed $value) : void
$view->foo = 'something';
stringvariable name
mixedvalue
__toString() : string
| uses | \Fuel\Core\View::render |
|---|
string__unset(string $key) : void
unset($view->foo);
stringvariable name
auto_filter(bool $filter) : \Fuel\Core\View
$view->auto_filter(false);
boolwhether 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 |
|---|
stringvariable name
mixedreferenced variable
boolWhether to filter the var on output
bind_global(string $key, mixed $value, bool $filter) : void
View::bind_global($key, $value);
stringvariable name
mixedreferenced variable
boolwhether 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);
stringview filename
objectarray 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.
stringThe variable name
mixedThe default value to return
\OutOfBoundsException |
|---|
mixedrender(\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\$filestring view filename
\FuelException |
|---|
stringset(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 |
|---|
stringvariable name or an array of variables
mixedvalue
boolwhether to filter the data or not
set_filename(string $file, $reverse) : \Fuel\Core\View
$view->set_filename($file);
stringview filename
\FuelException |
|---|
set_global(string $key, mixed $value, bool $filter) : void
View::set_global($name, $value);
stringvariable name or an array of variables
mixedvalue
boolwhether 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 |
|---|
stringvariable name or an array of variables
mixedvalue
get_data(string $scope) : array
It filters the data if necessary.
$data = $this->get_data();
stringlocal/glocal/all
arrayview dataprocess_file(bool $file_override) : string
The view data will be extracted to make local variables.
$output = $this->process_file();
boolFile override
stringunsanitize($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