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

Exposes a template to userland. More...

+ Collaboration diagram for Twig_TemplateWrapper:

Public Member Functions

 __construct (Twig_Environment $env, Twig_Template $template)
 This method is for internal use only and should never be called directly (use Twig_Environment::load() instead). More...
 
 render ($context=array())
 Renders the template. More...
 
 display ($context=array())
 Displays the template. More...
 
 hasBlock ($name, $context=array())
 Checks if a block is defined. More...
 
 getBlockNames ($context=array())
 Returns defined block names in the template. More...
 
 renderBlock ($name, $context=array())
 Renders a template block. More...
 
 displayBlock ($name, $context=array())
 Displays a template block. More...
 
 getSourceContext ()
 

Private Attributes

 $env
 
 $template
 

Detailed Description

Exposes a template to userland.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 17 of file TemplateWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_TemplateWrapper::__construct ( Twig_Environment  $env,
Twig_Template  $template 
)

This method is for internal use only and should never be called directly (use Twig_Environment::load() instead).

Definition at line 28 of file TemplateWrapper.php.

References $env, and $template.

29  {
30  $this->env = $env;
31  $this->template = $template;
32  }

Member Function Documentation

◆ display()

Twig_TemplateWrapper::display (   $context = array())

Displays the template.

Parameters
array$contextAn array of parameters to pass to the template

Definition at line 51 of file TemplateWrapper.php.

References $context.

52  {
53  $this->template->display($context);
54  }
$context
Definition: webdav.php:25

◆ displayBlock()

Twig_TemplateWrapper::displayBlock (   $name,
  $context = array() 
)

Displays a template block.

Parameters
string$nameThe block name to render
array$contextAn array of parameters to pass to the template

Definition at line 119 of file TemplateWrapper.php.

References $context, and $name.

120  {
121  $this->template->displayBlock($name, $this->env->mergeGlobals($context));
122  }
$context
Definition: webdav.php:25

◆ getBlockNames()

Twig_TemplateWrapper::getBlockNames (   $context = array())

Returns defined block names in the template.

Parameters
array$contextAn array of parameters to pass to the template
Returns
string[] An array of defined template block names

Definition at line 76 of file TemplateWrapper.php.

References $context.

77  {
78  return $this->template->getBlockNames($context);
79  }
$context
Definition: webdav.php:25

◆ getSourceContext()

Twig_TemplateWrapper::getSourceContext ( )
Returns
Twig_Source

Definition at line 127 of file TemplateWrapper.php.

128  {
129  return $this->template->getSourceContext();
130  }

◆ hasBlock()

Twig_TemplateWrapper::hasBlock (   $name,
  $context = array() 
)

Checks if a block is defined.

Parameters
string$nameThe block name
array$contextAn array of parameters to pass to the template
Returns
bool

Definition at line 64 of file TemplateWrapper.php.

References $context, and $name.

65  {
66  return $this->template->hasBlock($name, $context);
67  }
$context
Definition: webdav.php:25

◆ render()

Twig_TemplateWrapper::render (   $context = array())

Renders the template.

Parameters
array$contextAn array of parameters to pass to the template
Returns
string The rendered template

Definition at line 41 of file TemplateWrapper.php.

References $context.

42  {
43  return $this->template->render($context);
44  }
$context
Definition: webdav.php:25

◆ renderBlock()

Twig_TemplateWrapper::renderBlock (   $name,
  $context = array() 
)

Renders a template block.

Parameters
string$nameThe block name to render
array$contextAn array of parameters to pass to the template
Returns
string The rendered block

Definition at line 89 of file TemplateWrapper.php.

References $context, and $name.

90  {
91  $context = $this->env->mergeGlobals($context);
92  $level = ob_get_level();
93  ob_start();
94  try {
95  $this->template->displayBlock($name, $context);
96  } catch (Exception $e) {
97  while (ob_get_level() > $level) {
98  ob_end_clean();
99  }
100 
101  throw $e;
102  } catch (Throwable $e) {
103  while (ob_get_level() > $level) {
104  ob_end_clean();
105  }
106 
107  throw $e;
108  }
109 
110  return ob_get_clean();
111  }
$context
Definition: webdav.php:25

Field Documentation

◆ $env

Twig_TemplateWrapper::$env
private

Definition at line 19 of file TemplateWrapper.php.

Referenced by __construct().

◆ $template

Twig_TemplateWrapper::$template
private

Definition at line 20 of file TemplateWrapper.php.

Referenced by __construct().


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