Extension
The CMS Twig extension class implements the basic CMS Twig functions and filters.
class Cms\Twig\Extension
extends Twig\Extension\AbstractExtension
Extends
Class | Description |
---|---|
Twig\Extension\AbstractExtension
|
Properties
protected $controller : Cms\Classes\Controller
The instanciated CMS controller
Methods
public
assetsFunction ($type = null
)
: string | null
Renders registered assets of a given type or all types if $type not provided
Property | Type | Description |
---|---|---|
$type | mixed |
mixed
|
public
componentFunction (string $name, array $parameters = []
)
: string
Renders a component's default partial.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$parameters | array |
array
|
public
contentFunction (string $name, array $parameters = []
, boolean $throwException = false
)
: string | bool
Renders the requested content file.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$parameters | array |
array
|
$throwException | boolean |
boolean
|
public
displayBlock (string $name, $default = null
)
: string | null
Returns a layout block contents (or null if it doesn't exist) and removes the block.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$default | mixed |
mixed
|
public
endBlock (boolean $append = true
)
: void
Closes a layout block.
Property | Type | Description |
---|---|---|
$append | boolean |
boolean
|
public getController () : Cms\Classes\Controller
Gets the CMS controller instance
public getFilters () : array
Returns an array of filters this extension provides.
public getFunctions () : array
Returns an array of functions to add to the existing list.
public getTokenParsers () : array
Returns an array of token parsers this extension provides.
public
pageFilter (mixed $name, array $parameters = []
, boolean $routePersistence = true
)
: string | null
Returns the relative URL for the provided page
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
Specifies the Cms Page file name. |
$parameters | array |
array
Route parameters to consider in the URL. If boolean will be used as the value for $routePersistence |
$routePersistence | boolean |
boolean
Set to false to exclude the existing routing parameters from the generated URL |
public pageFunction () : string
Renders a page; used in the layout code to output the requested page.
public
partialFunction (string $name, array $parameters = []
, boolean $throwException = false
)
: string | bool
Renders the requested partial with the provided parameters. Optionally throw an exception if the partial cannot be found
Property | Type | Description |
---|---|---|
$name | string |
string
|
$parameters | array |
array
|
$throwException | boolean |
boolean
|
public
placeholderFunction (string $name, $default = null
)
: string | null
Renders placeholder content, without removing the block, must be called before the placeholder tag itself
Property | Type | Description |
---|---|---|
$name | string |
string
|
$default | mixed |
mixed
|
public setController (Cms\Classes\Controller $controller)
Sets the CMS controller instance
Property | Type | Description |
---|---|---|
$controller | Cms\Classes\Controller |
Cms\Classes\Controller
|
public startBlock (string $name) : void
Opens a layout block.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public themeFilter (mixed $url) : 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.
Property | Type | Description |
---|---|---|
$url | mixed |
mixed
Specifies the input to be turned into a URL (arrays will be passed to the AssetCombiner) |
public viteFunction (array $entrypoints, string $package) : Illuminate\Support\HtmlString
Generates Vite tags via Laravel's Vite Object.
Property | Type | Description |
---|---|---|
$entrypoints | array |
array
|
$package | string |
string
|