Contao Utils Bundle

TemplateUtil
in package

Table of Contents

Properties

$cache  : FilesystemAdapter
$container  : ContainerInterface
$containerUtil  : ContainerUtil
$twigFiles  : array<string|int, mixed>
Known files.
$kernel  : KernelInterface

Methods

__construct()  : mixed
findTemplates()  : array<string|int, mixed>
Return the files matching a GLOB pattern.
getAllTemplates()  : mixed
Get a list of all available templates.
getBundleTemplate()  : string
Find a particular template file within all bundles and return its path.
getPageAliasAsCssClass()  : mixed
getTemplate()  : string
Find a particular template file and return its path.
getTemplateGroup()  : array<string|int, mixed>
Return all template files of a particular group as array.
isTemplatePartEmpty()  : bool
Return true, if the template part is empty.
removeTemplateComment()  : mixed
remove TEMPLATE START/END comment from template if in debug mode.
renderTwigTemplate()  : string
Renders a twig template with data.

Properties

$twigFiles

Known files.

protected static array<string|int, mixed> $twigFiles = []

Methods

__construct()

public __construct(ContainerInterface $container) : mixed
Parameters
$container : ContainerInterface

findTemplates()

Return the files matching a GLOB pattern.

public findTemplates(string $path[, string $pattern = null ][, string $format = 'twig' ]) : array<string|int, mixed>
Parameters
$path : string
$pattern : string = null
$format : string = 'twig'
Return values
array<string|int, mixed>

getAllTemplates()

Get a list of all available templates.

public getAllTemplates() : mixed

getBundleTemplate()

Find a particular template file within all bundles and return its path.

public getBundleTemplate(string $name[, string $format = 'html.twig' ]) : string
Parameters
$name : string

The name of the template

$format : string = 'html.twig'

The file extension

Tags
throws
InvalidArgumentException

If $strFormat is unknown

throws
RuntimeException

If the template group folder is insecure

Return values
string

The path to the template file

getPageAliasAsCssClass()

public getPageAliasAsCssClass() : mixed

getTemplate()

Find a particular template file and return its path.

public getTemplate(string $name[, string $format = 'twig' ]) : string
Parameters
$name : string

The name of the template

$format : string = 'twig'

The file extension

Tags
throws
InvalidArgumentException

If $strFormat is unknown

throws
RuntimeException

If the template group folder is insecure

throws
Twig_Error_Loader
Return values
string

The path to the template file

getTemplateGroup()

Return all template files of a particular group as array.

public getTemplateGroup(string $prefix[, string $format = 'html.twig' ]) : array<string|int, mixed>
Parameters
$prefix : string

The template name prefix (e.g. "ce_")

$format : string = 'html.twig'

The file extension

Tags
coversNothing

As long as Controller::getTemplateGroup is not testable (ThemeModel…)

Return values
array<string|int, mixed>

An array of template names (html.twig templates without file extension, others with file extension)

isTemplatePartEmpty()

Return true, if the template part is empty.

public isTemplatePartEmpty([string $template = null ]) : bool

Template comments from debug and white spaces are treated as empty.

Datatypes other than string (typical null) are also treated as empty.

Parameters
$template : string = null
Return values
bool

removeTemplateComment()

remove TEMPLATE START/END comment from template if in debug mode.

public removeTemplateComment(mixed $template) : mixed
Parameters
$template : mixed

renderTwigTemplate()

Renders a twig template with data.

public renderTwigTemplate(string $name[, array<string|int, mixed> $context = [] ]) : string
Parameters
$name : string

The twig template name

$context : array<string|int, mixed> = []

The twig template context data

Tags
throws
InvalidArgumentException
throws
Twig_Error_Loader
throws
Twig_Error_Runtime
throws
Twig_Error_Syntax
Return values
string

        
On this page

Search results