ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailTemplateContextAdapter Class Reference

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

+ Collaboration diagram for ilMailTemplateContextAdapter:

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 Mustache.

In the old system, it was possible to gradually replace individual placeholders via the contexts. This is now done by Mustache 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 Mustache.

Definition at line 30 of file class.ilMailTemplateContextAdapter.php.

Member Function Documentation

◆ __get()

ilMailTemplateContextAdapter::__get ( string  $name)

Definition at line 64 of file class.ilMailTemplateContextAdapter.php.

References $context.

64  : string
65  {
66  foreach ($this->contexts as $context) {
67  $ret = $context->resolvePlaceholder($name, $this->context_parameter, $this->recipient);
68  if ($ret !== '') {
69  return $ret;
70  }
71  }
72 
73  return '';
74  }
$context
Definition: webdav.php:31

◆ __isset()

ilMailTemplateContextAdapter::__isset ( string  $name)

Definition at line 47 of file class.ilMailTemplateContextAdapter.php.

References $context.

47  : bool
48  {
49  foreach ($this->contexts as $context) {
50  $possible_placeholder = array_map(
51  static function ($placeholder): string {
52  return strtoupper($placeholder);
53  },
54  array_keys($context->getPlaceholders())
55  );
56  if (in_array($name, $possible_placeholder, true)) {
57  return true;
58  }
59  }
60 
61  return false;
62  }
$context
Definition: webdav.php:31

◆ withContext()

ilMailTemplateContextAdapter::withContext ( ilMailTemplateContext  $context)

Definition at line 40 of file class.ilMailTemplateContextAdapter.php.

References $context.

40  : self
41  {
42  $clone = clone $this;
43  $clone->contexts[] = $context;
44  return $clone;
45  }
$context
Definition: webdav.php:31

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