ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Twig_Loader_String Class Reference

Loads a template from a string. More...

+ Inheritance diagram for Twig_Loader_String:
+ Collaboration diagram for Twig_Loader_String:

Public Member Functions

 getSource ($name)
 Gets the source code of a template, given its name. More...
 
 getSourceContext ($name)
 Returns the source context for a given template logical name. More...
 
 exists ($name)
 Check if we have the source code of a template, given its name. More...
 
 getCacheKey ($name)
 Gets the cache key to use for the cache for a given template name. More...
 
 isFresh ($name, $time)
 Returns true if the template is still fresh. More...
 

Detailed Description

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)

Definition at line 30 of file String.php.

Member Function Documentation

◆ exists()

Twig_Loader_String::exists (   $name)

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

Parameters
string$nameThe name of the template to check if we can load
Returns
bool If the template source code is handled by this loader or not

Implements Twig_ExistsLoaderInterface.

Definition at line 44 of file String.php.

45  {
46  return true;
47  }

◆ getCacheKey()

Twig_Loader_String::getCacheKey (   $name)

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

Parameters
string$nameThe name of the template to load
Returns
string The cache key
Exceptions
Twig_Error_LoaderWhen $name is not found

Implements Twig_LoaderInterface.

Definition at line 49 of file String.php.

References $name.

50  {
51  return $name;
52  }
if($format !==null) $name
Definition: metadata.php:146

◆ getSource()

Twig_Loader_String::getSource (   $name)

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

Parameters
string$nameThe name of the template to load
Returns
string The template source code
Exceptions
Twig_Error_LoaderWhen $name is not found
Deprecated:
since 1.27 (to be removed in 2.0), implement Twig_SourceContextLoaderInterface

Implements Twig_LoaderInterface.

Definition at line 32 of file String.php.

References $name.

33  {
34  @trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
35 
36  return $name;
37  }
if($format !==null) $name
Definition: metadata.php:146

◆ getSourceContext()

Twig_Loader_String::getSourceContext (   $name)

Returns the source context for a given template logical name.

Parameters
string$nameThe template logical name
Returns
Twig_Source
Exceptions
Twig_Error_LoaderWhen $name is not found

Implements Twig_SourceContextLoaderInterface.

Definition at line 39 of file String.php.

References $name.

40  {
41  return new Twig_Source($name, $name);
42  }
if($format !==null) $name
Definition: metadata.php:146
Holds information about a non-compiled Twig template.
Definition: Source.php:19

◆ isFresh()

Twig_Loader_String::isFresh (   $name,
  $time 
)

Returns true if the template is still fresh.

Parameters
string$nameThe template name
int$timeTimestamp of the last modification time of the cached template
Returns
bool true if the template is fresh, false otherwise
Exceptions
Twig_Error_LoaderWhen $name is not found

Implements Twig_LoaderInterface.

Definition at line 54 of file String.php.

55  {
56  return true;
57  }

The documentation for this class was generated from the following file: