Stud.IP  6.0
Template Class Reference
Inheritance diagram for Template:
PhpTemplate

Public Member Functions

 __construct (protected string $template, protected Factory $factory, protected array $options=[])
 
 __set (string $name, mixed $value)
 
 __get (string $name)
 
 __isset (string $name)
 
 __unset (string $name)
 
 render (array $attributes=[], string|Template $layout=null)
 
 get_attribute (string $name)
 
 get_attributes ()
 
 set_attribute (string $name, mixed $value)
 
 set_attributes (array $attributes)
 
 clear_attributes ()
 
 clear_attribute (string $name)
 
 set_layout (Template|string|null $layout)
 
 get_layout ()
 

Protected Member Functions

 _render ()
 

Protected Attributes

array $attributes = []
 
Template null $layout = null
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( protected string  $template,
protected Factory  $factory,
protected array  $options = [] 
)

Constructor

Parameters
string$templatethe path of the template.
Factory$factorythe factory creating this template
array$optionsoptional array of options

Member Function Documentation

◆ __get()

__get ( string  $name)

__get() is a magic method utilized for reading data from inaccessible members. In this class it is used to get attributes for the template in a comfortable way.

Parameters
string$namethe name of the member field
Returns
mixed the value for the member field
See also
http://php.net/__get

◆ __isset()

__isset ( string  $name)

__isset() is a magic method triggered by calling isset() or empty() on inaccessible members. In this class it is used to check for attributes for the template in a comfortable way.

Parameters
string$namethe name of the member field
Returns
bool TRUE if that attribute exists, FALSE otherwise
See also
http://php.net/__isset

◆ __set()

__set ( string  $name,
mixed  $value 
)

__set() is a magic method run when writing data to inaccessible members. In this class it is used to set attributes for the template in a comfortable way.

Parameters
string$namethe name of the member field
mixed$valuethe value for the member field
See also
http://php.net/__set

◆ __unset()

__unset ( string  $name)

__unset() is a magic method invoked when unset() is used on inaccessible members. In this class it is used to check for attributes for the template in a comfortable way.

Parameters
string$namethe name of the member field
See also
http://php.net/__set

◆ _render()

_render ( )
abstractprotected

Parse, render and return the presentation.

Returns
string A string representing the rendered presentation.

◆ clear_attribute()

clear_attribute ( string  $name)

Clear an attribute associated with this template.

Parameters
string$nameThe name of the attribute to be cleared.

◆ clear_attributes()

clear_attributes ( )

Clear all attributes associated with this template.

◆ get_attribute()

get_attribute ( string  $name)

Returns the value of an attribute.

Parameters
string$nameAn attribute name.
Returns
mixed An attribute value.

◆ get_attributes()

get_attributes ( )

Set an array of attributes.

Returns
array An associative array of attributes and their associated values.

◆ get_layout()

get_layout ( )

Returns the template's layout.

Returns
Template|null

◆ render()

render ( array  $attributes = [],
string|Template  $layout = null 
)

Parse, render and return the presentation.

Parameters
array$attributesAn optional associative array of attributes and their associated values.
string | Template | null$layoutA name of a layout template.
Returns
string A string representing the rendered presentation.
Exceptions
TemplateNotFoundException

◆ set_attribute()

set_attribute ( string  $name,
mixed  $value 
)

Set an attribute.

Parameters
string$nameAn attribute name.
mixed$valueAn attribute value.

◆ set_attributes()

set_attributes ( array  $attributes)

Set an array of attributes.

Parameters
array$attributesAn associative array of attributes and their associated values.

◆ set_layout()

set_layout ( Template|string|null  $layout)

Set the template's layout.

Parameters
Template | string | null$layoutA name of a layout template or a layout template.
Exceptions
TemplateNotFoundException

Field Documentation

◆ $attributes

array $attributes = []
protected

◆ $layout

Template null $layout = null
protected

The documentation for this class was generated from the following file: