Contains template variables which are sent and received from templates.
The class provides a convenient way to set and get variables as normal PHP attributes. It also works as an iterator for traverals of the variables.
NOTE: If you want to assign an array be VERY careful. Do NOT write:
The next example sets and gets variables:
The next example shows all variables using the iterator.
Source for this file: /Template/src/variable_collection.php
Version: | //autogen// |
public ezcTemplateVariableCollection |
__construct(
[ $variables
= array()] )
Initialises an empty collection of variables. |
public mixed |
current(
)
Returns the current variable |
public array(string=>mixed) |
getVariableArray(
)
Returns all variables in an array. |
public string |
key(
)
Returns the current key. |
public mixed |
next(
)
Proceed to the next element. |
public bool |
removeVariable(
$name
)
Removes the variable named $name from the collection. |
public void |
rewind(
)
Iterator rewind method |
public bool |
valid(
)
Returns true if the iterator is at a valid location. |
public mixed |
__get(
$name
)
Returns the value of the variable $name. |
public bool |
__isset(
$name
)
Returns true if the variable $name is set. |
public void |
__set(
$name
, $value
)
Sets the value in $value to the variable named $name. |
Initialises an empty collection of variables.
Note: To initialise it with existing variables pass them as the $variables parameter.
Name | Type | Description |
---|---|---|
$variables |
array(string=>mixed) | An array of variables to initialise the collection with. The default is an empty collection. |
Returns the current variable
Method | Description |
---|---|
Iterator::current |
Returns all variables in an array.
Returns the current key.
Method | Description |
---|---|
Iterator::key |
Proceed to the next element.
Method | Description |
---|---|
Iterator::next |
Removes the variable named $name from the collection.
If the variable doesn't exist, it returns false.
Name | Type | Description |
---|---|---|
$name |
string | The name of the variable to remove. |
Iterator rewind method
Method | Description |
---|---|
Iterator::rewind |
Returns true if the iterator is at a valid location.
Method | Description |
---|---|
Iterator::valid |
Returns the value of the variable $name.
Name | Type | Description |
---|---|---|
$name |
string |
Returns true if the variable $name is set.
Name | Type | Description |
---|---|---|
$name |
string |
Sets the value in $value to the variable named $name.
NOTE: If you want to assign an array be VERY careful. Do NOT write:
Name | Type | Description |
---|---|---|
$name |
string | |
$value |
mixed |