PHP Class rex_fragment, redaxo

Mostrar archivo Open project: redaxo/redaxo Class Usage Examples

Public Methods

Method Description
__construct ( array $vars = [] ) Creates a fragment with the given variables.
__get ( string $name ) : mixed Magic getter to reference variables from within the fragment.
__isset ( string $name ) : boolean Magic method to check if a variable is set.
addDirectory ( string $dir ) Add a path to the fragment search path.
decorate ( string $filename, array $params ) Decorate the current fragment, with another fragment.
getVar ( string $name, string $default = null ) Returns the value of the given variable $name.
parse ( string $filename, boolean $delete_whitespaces = true ) : string Parses the variables of the fragment into the file $filename.
setVar ( string $name, mixed $value, boolean $escape = true ) Set the variable $name to the given value.

Protected Methods

Method Description
escape ( mixed $val ) : mixed Escapes the value $val for proper use in the gui.
i18n ( string $key ) : string Translate the given key $key.
subfragment ( string $filename, array $params = [] ) Include a Subfragment from within a fragment.

Method Details

__construct() public method

Creates a fragment with the given variables.
public __construct ( array $vars = [] )
$vars array A array of key-value pairs to pass as local parameters

__get() public method

Magic getter to reference variables from within the fragment.
public __get ( string $name ) : mixed
$name string The name of the variable to get
return mixed

__isset() public method

Magic method to check if a variable is set.
public __isset ( string $name ) : boolean
$name string The name of the variable to check
return boolean

addDirectory() public static method

Add a path to the fragment search path.
public static addDirectory ( string $dir )
$dir string A path to a directory where fragments can be found

decorate() public method

The decorated fragment receives the parameters which are passed to this method.
public decorate ( string $filename, array $params )
$filename string The filename of the fragment used for decoration
$params array A array of key-value pairs to pass as parameters

escape() protected method

Escapes the value $val for proper use in the gui.
protected escape ( mixed $val ) : mixed
$val mixed the value to escape
return mixed

getVar() public method

Returns the value of the given variable $name.
public getVar ( string $name, string $default = null )
$name string Variable name
$default string Default value

i18n() protected method

Translate the given key $key.
protected i18n ( string $key ) : string
$key string The key to translate
return string

parse() public method

Parses the variables of the fragment into the file $filename.
public parse ( string $filename, boolean $delete_whitespaces = true ) : string
$filename string the filename of the fragment to parse
$delete_whitespaces boolean
return string

setVar() public method

Set the variable $name to the given value.
public setVar ( string $name, mixed $value, boolean $escape = true )
$name string The name of the variable
$value mixed The value for the variable
$escape boolean Flag which indicates if the value should be escaped or not

subfragment() protected method

The Subfragment gets all variables of the current fragment, plus optional overrides from $params
protected subfragment ( string $filename, array $params = [] )
$filename string The filename of the fragment to use
$params array A array of key-value pairs to pass as local parameters