PHP Class Contao\TemplateLoader

The class stores template names and automatically loads the files upon their first usage. It uses a mapper array to support complex nesting and arbitrary subfolders to store the template files in. Usage: ClassLoader::addFile('moo_mediabox', 'core/templates');
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство Type Description
$files array Known files

Méthodes publiques

Méthode Description
addFile ( string $name, string $file ) Add a new template with its file path
addFiles ( array $files ) Add multiple new templates with their file paths
getDefaultPath ( string $template, string $format ) : string Return the path to the default template
getFiles ( ) : array Return the template files as array
getPath ( string $template, string $format, string $custom = 'templates' ) : string Return a template path
getPrefixedFiles ( string $prefix ) : array Return the files matching a prefix as array
initialize ( ) Find the templates in the Contao resource folders.

Method Details

addFile() public static méthode

Add a new template with its file path
public static addFile ( string $name, string $file )
$name string The template name
$file string The path to the template folder

addFiles() public static méthode

Add multiple new templates with their file paths
public static addFiles ( array $files )
$files array An array of files

getDefaultPath() public static méthode

Return the path to the default template
public static getDefaultPath ( string $template, string $format ) : string
$template string The template name
$format string The output format (e.g. "html5")
Résultat string The path to the default template file

getFiles() public static méthode

Return the template files as array
public static getFiles ( ) : array
Résultat array An array of files

getPath() public static méthode

Return a template path
public static getPath ( string $template, string $format, string $custom = 'templates' ) : string
$template string The template name
$format string The output format (e.g. "html5")
$custom string The custom templates folder (defaults to "templates")
Résultat string The path to the template file

getPrefixedFiles() public static méthode

Return the files matching a prefix as array
public static getPrefixedFiles ( string $prefix ) : array
$prefix string The prefix (e.g. "moo_")
Résultat array An array of matching files

initialize() public static méthode

Find the templates in the Contao resource folders.
public static initialize ( )

Property Details

$files protected_oe static_oe property

Known files
protected static array $files
Résultat array