Craft 3 Class Reference

Class craft\web\twig\TemplateLoader

Inheritance
craft\web\twig\TemplateLoader
Implements
Twig_ExistsLoaderInterface, Twig_LoaderInterface
Source Code
https://github.com/craftcms/cms/blob/master/src/web/twig/TemplateLoader.php

Protected Properties
Property Type Description Defined By
$view craft\web\View, null craft\web\twig\TemplateLoader
Public Methods
Method Description Defined By
__construct() Constructor craft\web\twig\TemplateLoader
exists() Check if we have the source code of a template, given its name. craft\web\twig\TemplateLoader
getCacheKey() Gets the cache key to use for the cache for a given template. craft\web\twig\TemplateLoader
getSourceContext() Returns the source context for a given template logical name. craft\web\twig\TemplateLoader
isFresh() Returns whether the cached template is still up-to-date with the latest template. craft\web\twig\TemplateLoader

Property Details

$view protected property #

protected craft\web\View, null $view null

Method Details

__construct() public method #

Constructor

public void __construct ( craft\web\View $view )
$view craft\web\View

exists() public method #

Check if we have the source code of a template, given its name.

public boolean exists ( $name )
$name string The name of the template to check if we can load
return boolean If the template source code is handled by this loader or not

getCacheKey() public method #

Gets the cache key to use for the cache for a given template.

public string getCacheKey ( $name )
$name string The name of the template to load
return string The cache key (the path to the template)
throws craft\web\twig\TemplateLoaderException if the template doesn’t exist

getSourceContext() public method #

Returns the source context for a given template logical name.

public Twig_Source getSourceContext ( $name )
$name string The template logical name
throws Twig_Error_Loader When $name is not found

isFresh() public method #

Returns whether the cached template is still up-to-date with the latest template.

public boolean isFresh ( $name, $time )
$name string The template name
$time integer The last modification time of the cached template
throws craft\web\twig\TemplateLoaderException if the template doesn’t exist