ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilMailTemplateContextAdapter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
31 {
32  public function __construct(
34  protected array $contexts,
35  protected array $context_parameter,
36  protected readonly Mustache_Engine $mustache_engine,
37  protected ?ilObjUser $recipient = null
38  ) {
39  }
40 
42  {
43  $clone = clone $this;
44  $clone->contexts[] = $context;
45  return $clone;
46  }
47 
48  public function __isset(string $name): bool
49  {
50  foreach ($this->contexts as $context) {
51  $possible_placeholder = array_map(
52  static function ($placeholder): string {
53  return strtoupper($placeholder);
54  },
55  array_keys($context->getPlaceholders())
56  );
57  if (in_array($name, $possible_placeholder, true)) {
58  return true;
59  }
60  }
61 
62  return false;
63  }
64 
65  public function __get(string $name): string
66  {
67  foreach ($this->contexts as $context) {
68  $ret = $context->resolvePlaceholder($name, $this->context_parameter, $this->recipient);
69  if (in_array($name, $context->getNestedPlaceholders(), true)) {
70  $ret = $this->mustache_engine->render($ret, $this);
71  }
72  if ($ret !== '') {
73  return $ret;
74  }
75  }
76 
77  return '';
78  }
79 }
$context
Definition: webdav.php:31
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This class forms an interface between the existing ILIAS mail contexts and the requirements of Mustac...
withContext(ilMailTemplateContext $context)
__construct(Container $dic, ilPlugin $plugin)