\rex_fragment

Methods declared here are available to be called from within a fragment-file, even if not public:.

Summary

Methods
Properties
Constants
__construct()
getVar()
setVar()
parse()
decorate()
__get()
__isset()
addDirectory()
No public properties found
No constants found
escape()
getSubfragment()
subfragment()
i18n()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(array  $vars = []) : mixed

Creates a fragment with the given variables.

Parameters

array $vars

A array of key-value pairs to pass as local parameters

Returns

mixed —

getVar()

getVar(string  $name, mixed  $default = null) : mixed

Returns the value of the given variable $name.

Parameters

string $name

Variable name

mixed $default

Default value

Returns

mixed —

setVar()

setVar(string  $name, mixed  $value, bool  $escape = true) : $this

Set the variable $name to the given value.

Parameters

string $name

The name of the variable

mixed $value

The value for the variable

bool $escape

Flag which indicates if the value should be escaped or not

Throws

\InvalidArgumentException

Returns

$this —

parse()

parse(string  $filename) : string

Parses the variables of the fragment into the file $filename.

Parameters

string $filename

the filename of the fragment to parse

Throws

\InvalidArgumentException
\rex_exception

Returns

string —

decorate()

decorate(string  $filename, array<string,mixed>  $params) : $this

Decorate the current fragment, with another fragment.

The decorated fragment receives the parameters which are passed to this method.

Parameters

string $filename

The filename of the fragment used for decoration

array $params

A array of key-value pairs to pass as parameters

Returns

$this —

__get()

__get(string  $name) : mixed

Magic getter to reference variables from within the fragment.

Parameters

string $name

The name of the variable to get

Returns

mixed —

__isset()

__isset(string  $name) : bool

Magic method to check if a variable is set.

Parameters

string $name

The name of the variable to check

Returns

bool —

addDirectory()

addDirectory(string  $dir) : mixed

Add a path to the fragment search path.

Parameters

string $dir

A path to a directory where fragments can be found

Returns

mixed —

escape()

escape(mixed  $value, string  $strategy = 'html') : mixed

Escapes the value $val for proper use in the gui.

Parameters

mixed $value

The value to escape

string $strategy

One of "html", "html_attr", "css", "js", "url"

Throws

\InvalidArgumentException

Returns

mixed —

getSubfragment()

getSubfragment(string  $filename, array<string,mixed>  $params = []) : string

Returns the content of a Subfragment from within a fragment.

The Subfragment gets all variables of the current fragment, plus optional overrides from $params

Parameters

string $filename

The filename of the fragment to use

array $params

A array of key-value pairs to pass as local parameters

Returns

string —

subfragment()

subfragment(string  $filename, array<string,mixed>  $params = []) : mixed

Include a Subfragment from within a fragment.

The Subfragment gets all variables of the current fragment, plus optional overrides from $params

Parameters

string $filename

The filename of the fragment to use

array $params

A array of key-value pairs to pass as local parameters

Returns

mixed —

i18n()

i18n(string  $key, string|int  ...$replacements) : string

Translate the given key $key.

Parameters

string $key

The key to translate

string|int $replacements variadic

A arbritary number of strings used for interpolating within the resolved message

Returns

string —

Translation for the key