Extension
extends AbstractExtension
in package
The CMS Twig extension class implements the basic CMS Twig functions and filters.
Tags
Table of Contents
- $controller : Controller
- __construct() : mixed
- Creates the extension instance.
- assetsFunction() : string
- Renders registered assets of a given type
- componentFunction() : string
- Renders a component's default content.
- contentFunction() : string
- Renders a content file.
- displayBlock() : mixed
- Returns a layout block contents and removes the block.
- endBlock() : mixed
- Closes a layout block.
- getFilters() : array<string|int, mixed>
- Returns a list of filters this extensions provides.
- getFunctions() : array<string|int, mixed>
- Returns a list of functions to add to the existing list.
- getNodeVisitors() : array<string|int, NodeVisitorInterface>
- Returns the node visitor instances to add to the existing list.
- getOperators() : array<string|int, array<string|int, mixed>>
- Returns a list of operators to add to the existing list.
- getTests() : array<string|int, TwigTest>
- Returns a list of tests to add to the existing list.
- getTokenParsers() : array<string|int, mixed>
- Returns a list of token parsers this extensions provides.
- pageFilter() : string
- Looks up the URL for a supplied page and returns it relative to the website root.
- pageFunction() : string
- Renders a page.
- partialFunction() : string
- Renders a partial.
- placeholderFunction() : string
- Renders a placeholder content, without removing the block, must be called before the placeholder tag itself
- startBlock() : mixed
- Opens a layout block.
- themeFilter() : string
- Converts supplied URL to a theme URL relative to the website root. If the URL provided is an array then the files will be combined.
Properties
$controller
protected
Controller
$controller
A reference to the CMS controller.
Methods
__construct()
Creates the extension instance.
public
__construct([Controller $controller = null ]) : mixed
Parameters
- $controller : Controller = null
-
The CMS controller object.
Return values
mixed —assetsFunction()
Renders registered assets of a given type
public
assetsFunction([mixed $type = null ]) : string
Parameters
- $type : mixed = null
Return values
string —Returns the component default contents.
componentFunction()
Renders a component's default content.
public
componentFunction(string $name[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
- $name : string
-
Specifies the component name.
- $parameters : array<string|int, mixed> = []
-
A optional list of parameters to pass to the component.
Return values
string —Returns the component default contents.
contentFunction()
Renders a content file.
public
contentFunction(string $name[, array<string|int, mixed> $parameters = [] ]) : string
Parameters
- $name : string
-
Specifies the content block name.
- $parameters : array<string|int, mixed> = []
-
A optional list of parameters to pass to the content.
Return values
string —Returns the file contents.
displayBlock()
Returns a layout block contents and removes the block.
public
displayBlock(string $name[, string $default = null ]) : mixed
Parameters
- $name : string
-
Specifies the block name
- $default : string = null
-
The default placeholder contents.
Return values
mixed —Returns the block contents string or null of the block doesn't exist
endBlock()
Closes a layout block.
public
endBlock([mixed $append = true ]) : mixed
Parameters
- $append : mixed = true
Return values
mixed —getFilters()
Returns a list of filters this extensions provides.
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of filters
getFunctions()
Returns a list of functions to add to the existing list.
public
getFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of functions
getNodeVisitors()
Returns the node visitor instances to add to the existing list.
public
getNodeVisitors() : array<string|int, NodeVisitorInterface>
Return values
array<string|int, NodeVisitorInterface> —getOperators()
Returns a list of operators to add to the existing list.
public
getOperators() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>> —First array of unary operators, second array of binary operators
getTests()
Returns a list of tests to add to the existing list.
public
getTests() : array<string|int, TwigTest>
Return values
array<string|int, TwigTest> —getTokenParsers()
Returns a list of token parsers this extensions provides.
public
getTokenParsers() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of token parsers
pageFilter()
Looks up the URL for a supplied page and returns it relative to the website root.
public
pageFilter(mixed $name[, array<string|int, mixed> $parameters = [] ][, bool $routePersistence = true ]) : string
Parameters
- $name : mixed
-
Specifies the Cms Page file name.
- $parameters : array<string|int, mixed> = []
-
Route parameters to consider in the URL.
- $routePersistence : bool = true
-
By default the existing routing parameters will be included when creating the URL, set to false to disable this feature.
Return values
string —pageFunction()
Renders a page.
public
pageFunction() : string
This function should be used in the layout code to output the requested page.
Return values
string —Returns the page contents.
partialFunction()
Renders a partial.
public
partialFunction(string $name[, array<string|int, mixed> $parameters = [] ][, bool $throwException = false ]) : string
Parameters
- $name : string
-
Specifies the partial name.
- $parameters : array<string|int, mixed> = []
-
A optional list of parameters to pass to the partial.
- $throwException : bool = false
-
Throw an exception if the partial is not found.
Return values
string —Returns the partial contents.
placeholderFunction()
Renders a placeholder content, without removing the block, must be called before the placeholder tag itself
public
placeholderFunction(mixed $name[, mixed $default = null ]) : string
Parameters
- $name : mixed
- $default : mixed = null
Return values
string —Returns the placeholder contents.
startBlock()
Opens a layout block.
public
startBlock(string $name) : mixed
Parameters
- $name : string
-
Specifies the block name
Return values
mixed —themeFilter()
Converts supplied URL to a theme URL relative to the website root. If the URL provided is an array then the files will be combined.
public
themeFilter(mixed $url) : string
Parameters
- $url : mixed
-
Specifies the theme-relative URL