Alias ViewHelper <f:alias>
Declares new variables which are aliases of other variables. Takes a "map"-Parameter which is an associative array which defines the shorthand mapping.
The variables are only declared inside the <f:alias>...</f:alias>
tag. After the
closing tag, all declared variables are removed again.
Using this ViewHelper can be a sign of weak architecture. If you end up using it extensively you might want to fine-tune your "view model" (the data you assign to the view).
Examples
Single alias
<f:alias map="{x: 'foo'}">{x}</f:alias>
Copied!
Output:
foo
Copied!
Multiple mappings
<f:alias map="{x: foo.bar.baz, y: foo.bar.baz.name}">
{x.name} or {y}
</f:alias>
Copied!
Output:
[name] or [name]
Copied!
Depending on {foo.bar.baz}
.
Source code
Go to the source code of this ViewHelper: AliasViewHelper.php (GitHub).
Arguments
The following arguments are available for the alias ViewHelper:
map
-
- Type
- array
- Required
- 1
Array that specifies which variables should be mapped to which alias