PHP Класс Kohana_Twig, kohana-twig

Автор: Jonathan Geiger
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_data Local data
$_environment The environment the view is attached to
$_extension The extension of the file
$_file The file to render
$_global_data Global data, merged just before compilation

Открытые методы

Метод Описание
__construct ( $file = NULL, array $data = NULL, $env = 'default' ) Constructor
__get ( $key ) : mixed Magic method. See get()
__isset ( $key ) : boolean Magic method, determines if a variable is set and is not NULL.
__set ( $key, $value ) : void Magic method, calls set() with the same parameters.
__toString ( ) : string Magic method, returns the output of render(). If any exceptions are thrown, the exception output will be returned instead.
__unset ( $key ) : void Magic method, unsets a given variable.
as_array ( ) : array Returns the final data plus global data merged as an array
bind ( $key, &$value ) : View Assigns a value by reference. 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:
bind_global ( $key, &$value ) : View Assigns a global variable by reference, similar to the bind() method.
environment ( ) : Twig_Environment Returns the environment this view is attached to
extension ( ) : string Returns the template's extension
factory ( string $file = NULL, string $data = NULL, string $env = 'default' ) : void Factory for Twigs
filename ( ) : string Returns the templates filename (sans extension)
get ( $key, $default = NULL ) : mixed Searches for the given variable and returns its value.
path ( ) : string Returns the full path of the current template ($filename + $extension)
render ( $file = NULL ) : string Renders the view object to a string. Global and local data are merged and extracted to create local variables within the view file.
set ( $key, $value = NULL ) : View Assigns a variable by name. Assigned values will be available as a variable within the view file:
set_extension ( string $extension ) : void Sets a file exension
set_filename ( $file ) : View Sets the view filename.
set_global ( $key, $value = NULL ) : View Sets a global variable, similar to the set() method.

Описание методов

__construct() публичный Метод

Constructor
Автор: Jonathan Geiger
public __construct ( $file = NULL, array $data = NULL, $env = 'default' )
$data array

__get() публичный Метод

Magic method. See get()
public __get ( $key ) : mixed
Результат mixed

__isset() публичный Метод

Magic method, determines if a variable is set and is not NULL.
public __isset ( $key ) : boolean
Результат boolean

__set() публичный Метод

Magic method, calls set() with the same parameters.
public __set ( $key, $value ) : void
Результат void

__toString() публичный Метод

Magic method, returns the output of render(). If any exceptions are thrown, the exception output will be returned instead.
public __toString ( ) : string
Результат string

__unset() публичный Метод

Magic method, unsets a given variable.
public __unset ( $key ) : void
Результат void

as_array() публичный Метод

Returns the final data plus global data merged as an array
Автор: Jonathan Geiger
public as_array ( ) : array
Результат array

bind() публичный Метод

This reference can be accessed as $ref within the view $view->bind('ref', $bar);
public bind ( $key, &$value ) : View
Результат View

bind_global() публичный статический Метод

Assigns a global variable by reference, similar to the bind() method.
public static bind_global ( $key, &$value ) : View
Результат View

environment() публичный Метод

Returns the environment this view is attached to
Автор: Jonathan Geiger
public environment ( ) : Twig_Environment
Результат Twig_Environment

extension() публичный Метод

Returns the template's extension
Автор: Jonathan Geiger
public extension ( ) : string
Результат string

factory() публичный статический Метод

Factory for Twigs
Автор: Jonathan Geiger
public static factory ( string $file = NULL, string $data = NULL, string $env = 'default' ) : void
$file string
$data string
$env string
Результат void

filename() публичный Метод

Returns the templates filename (sans extension)
Автор: Jonathan Geiger
public filename ( ) : string
Результат string

get() публичный Метод

Local variables will be returned before global variables.
public get ( $key, $default = NULL ) : mixed
Результат mixed

path() публичный Метод

Returns the full path of the current template ($filename + $extension)
Автор: Jonathan Geiger
public path ( ) : string
Результат string

render() публичный Метод

Note: Global variables with the same key name as local variables will be overwritten by the local variable.
public render ( $file = NULL ) : string
Результат string

set() публичный Метод

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'));
public set ( $key, $value = NULL ) : View
Результат View

set_extension() публичный Метод

Sets a file exension
Автор: Jonathan Geiger
public set_extension ( string $extension ) : void
$extension string
Результат void

set_filename() публичный Метод

Sets the view filename.
public set_filename ( $file ) : View
Результат View

set_global() публичный статический Метод

The name is a bit of a misnomer, since Twig has no real concept of "global" variables, just one context available to the entire view structure. However, it is implemented to provide an API similar to Kohana_View, as well as to allow passing a default set of values (perhaps from the 'context' configuration) that can be overridden by set(). The global data persists across environments.
public static set_global ( $key, $value = NULL ) : View
Результат View

Описание свойств

$_data защищенное свойство

Local data
protected $_data

$_environment защищенное свойство

The environment the view is attached to
protected $_environment

$_extension защищенное свойство

The extension of the file
protected $_extension

$_file защищенное свойство

The file to render
protected $_file

$_global_data защищенное статическое свойство

Global data, merged just before compilation
protected static $_global_data