ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_ContainerRuntimeLoader Class Reference

Lazily loads Twig runtime implementations from a PSR-11 container. More...

+ Inheritance diagram for Twig_ContainerRuntimeLoader:
+ Collaboration diagram for Twig_ContainerRuntimeLoader:

Public Member Functions

 __construct (ContainerInterface $container)
 
 load ($class)
 Creates the runtime implementation of a Twig element (filter/function/test). More...
 

Private Attributes

 $container
 

Detailed Description

Lazily loads Twig runtime implementations from a PSR-11 container.

Note that the runtime services MUST use their class names as identifiers.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com
Robin Chalas robin.nosp@m..cha.nosp@m.las@g.nosp@m.mail.nosp@m..com

Definition at line 22 of file ContainerRuntimeLoader.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_ContainerRuntimeLoader::__construct ( ContainerInterface  $container)

Definition at line 26 of file ContainerRuntimeLoader.php.

References $container.

27  {
28  $this->container = $container;
29  }

Member Function Documentation

◆ load()

Twig_ContainerRuntimeLoader::load (   $class)

Creates the runtime implementation of a Twig element (filter/function/test).

Parameters
string$classA runtime class
Returns
object|null The runtime instance or null if the loader does not know how to create the runtime for this class

Implements Twig_RuntimeLoaderInterface.

Definition at line 31 of file ContainerRuntimeLoader.php.

32  {
33  if ($this->container->has($class)) {
34  return $this->container->get($class);
35  }
36  }

Field Documentation

◆ $container

Twig_ContainerRuntimeLoader::$container
private

Definition at line 24 of file ContainerRuntimeLoader.php.

Referenced by __construct().


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