Cms\Twig\Extension

Overview

Extension implements the basic CMS Twig functions and filters.

Extends
  • Twig\Extension\AbstractExtension
Implements
  • Twig\Extension\ExtensionInterface

Protected Properties

protected Cms\Classes\Controller $controller

controller reference


Public Methods

public __construct()

public __construct($controller = null): void

__construct the extension instance.

public abortFunction()

public abortFunction(int $code, string|false $message = ''): void

abortFunction will abort the successful page cycle

public static addExtensionToTwig()

public static addExtensionToTwig($twig, $controller = null): void

addExtensionToTwig adds this extension to the Twig environment and also creates a hook for others.

public ajaxHandlerFunction()

public ajaxHandlerFunction(string $name = ''): void

ajaxHandlerFunction runs an ajax handler

public assetsFunction()

public assetsFunction($type = null): string 

assetsFunction renders registered assets of a given type

public componentFunction()

public componentFunction(string $name, array $parameters = []): string 

componentFunction renders a component's default content.

public contentFilter()

public contentFilter(string $content): string 

contentFilter processes content for links and snippets

public contentFunction()

public contentFunction(
    $name,
    $parameters = [],
    $throwException = false
): string 

contentFunction renders a partial based on the file name. The parameters are an optional list of view variables, otherwise pass false to render nothing and check the existence. An exception can be thrown if nothing is found.

public displayBlock()

public displayBlock(string $name, string $default = null): string|null 

displayBlock returns a layout block contents and removes the block.

public endBlock()

public endBlock($append = true): void

endBlock closes a layout block.

public getFilters()

public getFilters(): array 

getFilters returns a list of filters this extension provides.

public getFunctions()

public getFunctions(): array 

getFunctions returns a list of functions to add to the existing list.

public getNodeVisitors()

public getNodeVisitors(): array 

getNodeVisitors returns a list of node visitors this extension provides.

public getTokenParsers()

public getTokenParsers(): array 

getTokenParsers returns a list of token parsers this extension provides.

public hasContentFunction()

public hasContentFunction($name): bool 

hasContentFunction checks the content existence without rendering it.

public hasPartialFunction()

public hasPartialFunction($name): bool 

hasPartialFunction checks the partials existence without rendering it.

public hasPlaceholderFunction()

public hasPlaceholderFunction($name): void

hasPlaceholderFunction checks that a placeholder exists without rendering it

public pageFilter()

public pageFilter(
    mixed $name,
    array $parameters = [],
    bool $routePersistence = true
): string 

pageFilter looks up the URL for a supplied page name and returns it relative to the website root, including route parameters. Parameters can be persisted from the current page parameters.

public pageFunction()

public pageFunction(array|null $context = null): string 

pageFunction renders a page. This function should be used in the layout code to output the requested page.

public partialFunction()

public partialFunction(
    $name,
    $parameters = [],
    $throwException = false
): string 

partialFunction renders a partial based on the partial name. The parameters are an optional list of view variables. An exception can be thrown if nothing is found.

public placeholderFunction()

public placeholderFunction($name, $default = null): string 

placeholderFunction renders a placeholder content, without removing the block, must be called before the placeholder tag itself

public redirectFunction()

public redirectFunction(string $to, int $code = [], $code = 302): void

redirectFunction will redirect the response to a theme page or URL

public responseFunction()

public responseFunction(
    Illuminate\Contracts\View\View|string|array|null $content = '',
    int|null $status = null,
    array $headers = []
): void

responseFunction returns a new response from the application.

public setBlock()

public setBlock($name, $value): void

setBlock sets a block value as a variable.

public startBlock()

public startBlock(string $name): void

startBlock opens a layout block.

public themeFilter()

public themeFilter(mixed $url): string 

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.

Show inherited public methods

Inherited Public Methods

  • getOperators() - (defined in Twig\Extension\AbstractExtension)
  • getTests() - (defined in Twig\Extension\AbstractExtension)