Twig_Loader_String

Implements\Twig\Loader\LoaderInterface, \Twig\Loader\ExistsLoaderInterface, \Twig\Loader\SourceContextLoaderInterface

Loads a template from a string.

This loader should NEVER be used. It only exists for Twig internal purposes.

When using this loader with a cache mechanism, you should know that a new cache key is generated each time a template content "changes" (the cache key being the source code of the template). If you don't want to see your cache grows out of control, you need to take care of clearing the old cache file by yourself.

deprecated

since 1.18.1 (to be removed in 2.0)

internal
author

Fabien Potencier fabien@symfony.com

package

Default

Methods

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

exists(string $name): boolean

Arguments

$name

string

The name of the template to check if we can load

Response

boolean

If the template source code is handled by this loader or not

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

getCacheKey(string $name): string

Arguments

$name

string

The name of the template to load

Response

string

The cache key

Gets the source code of a template, given its name.

getSource(string $name): string

Arguments

$name

string

The name of the template to load

Response

string

The template source code

Returns the source context for a given template logical name.

getSourceContext(string $name): \Twig\Source

Arguments

$name

string

The template logical name

Response

\Twig\Source

Returns true if the template is still fresh.

isFresh(string $name,integer $time): boolean

Arguments

$name

string

The template name

$time

integer

Timestamp of the last modification time of the cached template

Response

boolean

true if the template is fresh, false otherwise