ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Mail\TemplateEngine\MailTemplateContextAdapter Class Reference

This class forms an interface between the existing ILIAS mail contexts and the requirements of the template engine. More...

+ Collaboration diagram for ILIAS\Mail\TemplateEngine\MailTemplateContextAdapter:

Public Member Functions

 withContext (ilMailTemplateContext $context)
 
 __isset (string $name)
 
 __get (string $name)
 

Detailed Description

This class forms an interface between the existing ILIAS mail contexts and the requirements of the template engine.

In the old system, it was possible to gradually replace individual placeholders via the contexts. This is now done by the template engine and requires a single source. If a placeholder does not exist in this source, then it will be replaced with NULL. Mustache takes two steps to find the placeholder. On the one hand the check whether it would be theoretically possible and the actual query for the value if the check is successful. This is done in this class using the two magic methods. With the introduction of this interface, the ILIAS mail contexts do not have to be changed for the template engine.

Definition at line 35 of file MailTemplateContextAdapter.php.

Member Function Documentation

◆ __get()

ILIAS\Mail\TemplateEngine\MailTemplateContextAdapter::__get ( string  $name)

Definition at line 70 of file MailTemplateContextAdapter.php.

70 : string
71 {
72 foreach ($this->contexts as $context) {
73 $ret = $context->resolvePlaceholder($name, $this->context_parameter, $this->recipient);
74 if (\in_array($name, $context->getNestedPlaceholders(), true)) {
75 $ret = $this->template_engine->render($ret, $this);
76 }
77 if ($ret !== '') {
78 return $ret;
79 }
80 }
81
82 return '';
83 }

◆ __isset()

ILIAS\Mail\TemplateEngine\MailTemplateContextAdapter::__isset ( string  $name)

Definition at line 53 of file MailTemplateContextAdapter.php.

53 : bool
54 {
55 foreach ($this->contexts as $context) {
56 $possible_placeholder = array_map(
57 static function ($placeholder): string {
58 return strtoupper($placeholder);
59 },
60 array_keys($context->getPlaceholders())
61 );
62 if (\in_array($name, $possible_placeholder, true)) {
63 return true;
64 }
65 }
66
67 return false;
68 }

◆ withContext()

ILIAS\Mail\TemplateEngine\MailTemplateContextAdapter::withContext ( ilMailTemplateContext  $context)

Definition at line 46 of file MailTemplateContextAdapter.php.

46 : self
47 {
48 $clone = clone $this;
49 $clone->contexts[] = $context;
50 return $clone;
51 }

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