Documentation

rex_fragment
in package

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

Tags
phpstan-method

void subfragment(string $filename, array $params = [])

phpstan-method

string getSubfragment(string $filename, array $params = [])

phpstan-method

string i18n(string $key, ...$replacements)

phpstan-method

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

Table of Contents

Methods

__construct()  : mixed
Creates a fragment with the given variables.
__get()  : mixed
Magic getter to reference variables from within the fragment.
__isset()  : bool
Magic method to check if a variable is set.
addDirectory()  : void
Add a path to the fragment search path.
decorate()  : $this
Decorate the current fragment, with another fragment.
getVar()  : mixed
Returns the value of the given variable $name.
parse()  : string
Parses the variables of the fragment into the file $filename.
setVar()  : $this
Set the variable $name to the given value.
escape()  : mixed
Escapes the value $val for proper use in the gui.
getSubfragment()  : string
Returns the content of a Subfragment from within a fragment.
i18n()  : string
Translate the given key $key.
subfragment()  : void
Include a Subfragment from within a fragment.

Methods

__construct()

Creates a fragment with the given variables.

public __construct([array<string, mixed> $vars = [] ]) : mixed
Parameters
$vars : array<string, mixed> = []

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

__get()

Magic getter to reference variables from within the fragment.

public __get(string $name) : mixed
Parameters
$name : string

The name of the variable to get

__isset()

Magic method to check if a variable is set.

public __isset(string $name) : bool
Parameters
$name : string

The name of the variable to check

Return values
bool

addDirectory()

Add a path to the fragment search path.

public static addDirectory(string $dir) : void
Parameters
$dir : string

A path to a directory where fragments can be found

decorate()

Decorate the current fragment, with another fragment.

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

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

Parameters
$filename : string

The filename of the fragment used for decoration

$params : array<string, mixed>

A array of key-value pairs to pass as parameters

Return values
$this

getVar()

Returns the value of the given variable $name.

public getVar(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string

Variable name

$default : mixed = null

Default value

parse()

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

public parse(string $filename) : string
Parameters
$filename : string

the filename of the fragment to parse

Tags
throws
InvalidArgumentException
Return values
string

setVar()

Set the variable $name to the given value.

public setVar(string $name, mixed $value[, bool $escape = true ]) : $this
Parameters
$name : string

The name of the variable

$value : mixed

The value for the variable

$escape : bool = true

Flag which indicates if the value should be escaped or not

Tags
throws
InvalidArgumentException
Return values
$this

escape()

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

protected escape(T $value[, string $strategy = 'html' ]) : mixed
Parameters
$value : T

The value to escape

$strategy : string = 'html'

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

Tags
template

T

psalm-param

'html'|'html_simplified'|'html_attr'|'js'|'css'|'url' $strategy

throws
InvalidArgumentException
psalm-return

(T is Stringable ? string : T)

getSubfragment()

Returns the content of a Subfragment from within a fragment.

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

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

Parameters
$filename : string

The filename of the fragment to use

$params : array<string, mixed> = []

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

Return values
string

i18n()

Translate the given key $key.

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

The key to translate

$replacements : string|int

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

Return values
string

Translation for the key

subfragment()

Include a Subfragment from within a fragment.

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

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

Parameters
$filename : string

The filename of the fragment to use

$params : array<string, mixed> = []

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


        
On this page

Search results