class TwigExtension extends AbstractExtension implements GlobalsInterface

Template engine functions, filters and tests.

Properties

protected array $protectedModels Model classes requires control panel access
protected array $protectedServices Protected services requires control panel access
protected array $userProtectedServices Protected services requires logged user
protected object $markdownParser Markdown parser

Methods

array
getGlobals()

Rempate engine global variables

array
getFunctions()

Template engine functions

string
getPaginatorUrl(string $pageUrl, integer $page, boolean $full = true, boolean $withLanguagePath = false)

Get paginator url

bool
hasExtension(string $extension)

Return true if extension exists

CacheInterface
getCache()

Get cache

array|null
getRelationsMap()

Get relatins type map (morph map)

string
getCurrentUrl(bool $full = true)

Return url link with current language code

string
loadComponent(string $name, array|null $params = [], string|null $type = null)

Load component

string
getLanguage()

Get current page language

string
loadLibraryFile(string $library, string $fileName)

Load Ui library file

mixed
getSessionVar(string $name, mixed $default = null)

Get session var

void
setSessionVar(string $name, mixed $value)

Set session var

string|false
getPageUrl(string $routeName, string|null $extension, array $params = [], bool $relative = false, string|null $language = null)

Get page url

array
getFilters()

Template engine filters

array
getTests()

Template engine tests

array
getTokenParsers()

Template engine tags

mixed
getService(string $name)

Get service from container

array|false
getDirectoryFiles(string $path, bool $recursive = false, string $fileSystemName = 'storage')

Get directory contents

Model|false
createModel(string|null $modelClass, string|null $extension = null, bool $showError = false)

Create model

string|null
getFileType(string|null $fileName)

Return file type

array|null
getCurrentLanguage()

Return current language

mixed
getOption(string $name, mixed $default = null)

Get option

array
getOptions(string $searchKey, bool $compactKeys = false)

Get options

object|null
create(string $class, string|null $extension = null)

Create obj

Response|null
fetch(string $url)

Fetch url

void
extractArray(array $context, array $data)

Exctract array as local variables in template

string
parseMarkdown($content, $context = [])

Parse Markdown

Details

at line 84
array getGlobals()

Rempate engine global variables

Return Value

array

at line 102
array getFunctions()

Template engine functions

Return Value

array

at line 185
string getPaginatorUrl(string $pageUrl, integer $page, boolean $full = true, boolean $withLanguagePath = false)

Get paginator url

Parameters

string $pageUrl
integer $page
boolean $full
boolean $withLanguagePath

Return Value

string

at line 198
bool hasExtension(string $extension)

Return true if extension exists

Parameters

string $extension

Return Value

bool

at line 210
CacheInterface getCache()

Get cache

Return Value

CacheInterface

at line 220
array|null getRelationsMap()

Get relatins type map (morph map)

Return Value

array|null

at line 231
string getCurrentUrl(bool $full = true)

Return url link with current language code

Parameters

bool $full

Return Value

string

at line 246
string loadComponent(string $name, array|null $params = [], string|null $type = null)

Load component

Parameters

string $name
array|null $params
string|null $type

Return Value

string

at line 259
string getLanguage()

Get current page language

Return Value

string

at line 271
string loadLibraryFile(string $library, string $fileName)

Load Ui library file

Parameters

string $library
string $fileName

Return Value

string

at line 285
mixed getSessionVar(string $name, mixed $default = null)

Get session var

Parameters

string $name
mixed $default

Return Value

mixed

at line 297
void setSessionVar(string $name, mixed $value)

Set session var

Parameters

string $name
mixed $value

Return Value

void

at line 312
string|false getPageUrl(string $routeName, string|null $extension, array $params = [], bool $relative = false, string|null $language = null)

Get page url

Parameters

string $routeName
string|null $extension
array $params
bool $relative
string|null $language

Return Value

string|false

at line 338
array getFilters()

Template engine filters

Return Value

array

at line 388
array getTests()

Template engine tests

Return Value

array

at line 402
array getTokenParsers()

Template engine tags

Return Value

array

at line 417
mixed getService(string $name)

Get service from container

Parameters

string $name

Return Value

mixed

at line 443
array|false getDirectoryFiles(string $path, bool $recursive = false, string $fileSystemName = 'storage')

Get directory contents

Parameters

string $path
bool $recursive
string $fileSystemName

Return Value

array|false

at line 462
Model|false createModel(string|null $modelClass, string|null $extension = null, bool $showError = false)

Create model

Parameters

string|null $modelClass
string|null $extension
bool $showError

Return Value

Model|false

at line 477
string|null getFileType(string|null $fileName)

Return file type

Parameters

string|null $fileName

Return Value

string|null

at line 487
array|null getCurrentLanguage()

Return current language

Return Value

array|null

at line 502
mixed getOption(string $name, mixed $default = null)

Get option

Parameters

string $name
mixed $default

Return Value

mixed

at line 514
array getOptions(string $searchKey, bool $compactKeys = false)

Get options

Parameters

string $searchKey
bool $compactKeys

Return Value

array

at line 526
object|null create(string $class, string|null $extension = null)

Create obj

Parameters

string $class
string|null $extension

Return Value

object|null

at line 539
Response|null fetch(string $url)

Fetch url

Parameters

string $url

Return Value

Response|null

at line 553
void extractArray(array $context, array $data)

Exctract array as local variables in template

Parameters

array $context
array $data

Return Value

void

at line 570
string parseMarkdown($content, $context = [])

Parse Markdown

Parameters

$content
$context

Return Value

string