Extension

The System Twig extension class implements common Twig functions and filters.

 class System\Twig\Extension
extends Twig\Extension\AbstractExtension

Extends

Properties

protected $markupManager : System\Classes\MarkupManager

A reference to the markup manager instance.

Methods

public __construct ()

Creates the extension instance.

Returns
mixed

public appFilter (mixed $url) : string

Converts supplied URL to one relative to the website root.

Parameters
Property Description
$url
mixed

Specifies the application-relative URL

Returns
string

public assetFilter (string $file) : string

Converts supplied file to a URL relative to the app.asset_url config.

Parameters
Property Description
$file
string

Specifies the asset-relative file

Returns
string

public getFilters () : array

Returns a list of filters this extensions provides.

Returns
array

An array of filters

public getFunctions () : array

Returns a list of functions to add to the existing list.

Returns
array

An array of functions

public getTokenParsers () : array

Returns a list of token parsers this extensions provides.

Returns
array

An array of token parsers

public imageHeightFilter (mixed $image) : int

Gets the height in pixels of the provided image source

Parameters
Property Description
$image
mixed

Supported values below: ['disk' => Illuminate\Filesystem\FilesystemAdapter, 'path' => string, 'source' => string, 'fileModel' => FileModel|void], instance of Winter\Storm\Database\Attach\File, string containing URL or path accessible to the application's filesystem manager

Returns
int

public imageWidthFilter (mixed $image) : int

Gets the width in pixels of the provided image source

Parameters
Property Description
$image
mixed

Supported values below: ['disk' => Illuminate\Filesystem\FilesystemAdapter, 'path' => string, 'source' => string, 'fileModel' => FileModel|void], instance of Winter\Storm\Database\Attach\File, string containing URL or path accessible to the application's filesystem manager

Returns
int

public mediaFilter (string $file) : string

Converts supplied file to a URL relative to the media library.

Parameters
Property Description
$file
string

Specifies the media-relative file

Returns
string

public resizeFilter (mixed $image, int | bool | null $width = null, int | bool | null $height = null, array $options = []) : string

Converts supplied input into a URL that will return the desired resized image

Parameters
Property Description
$image
mixed

Supported values below: ['disk' => Illuminate\Filesystem\FilesystemAdapter, 'path' => string, 'source' => string, 'fileModel' => FileModel|void], instance of Winter\Storm\Database\Attach\File, string containing URL or path accessible to the application's filesystem manager

$width
int | bool | null

Desired width of the resized image

$height
int | bool | null

Desired height of the resized image

$options
array

Array of options to pass to the resizer

Returns
string
Copyright © 2024 Winter CMS