ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilMailTemplateContextDefinitionProcessor.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  protected ?string $component = null;
24  protected bool $in_mailtemplates = false;
25 
29  protected array $mail_templates = [];
30 
31  public function __construct(protected ilDBInterface $db)
32  {
33  }
34 
35  public function purge(): void
36  {
37  }
38 
39  public function beginComponent(string $component, string $type): void
40  {
41  $this->component = $type . '/' . $component;
42  $this->in_mailtemplates = false;
43  $this->mail_templates = [];
44  }
45 
46  public function endComponent(string $component, string $type): void
47  {
48  $this->component = null;
49  $this->in_mailtemplates = false;
50  $this->mail_templates = [];
51  }
52 
53  public function beginTag(string $name, array $attributes): void
54  {
55  if ($name === 'mailtemplates') {
56  $this->in_mailtemplates = true;
57  return;
58  }
59  if ($name !== 'context' || !$this->in_mailtemplates) {
60  return;
61  }
62 
63  $component = $attributes['component'] ?? null;
64  if (!$component) {
65  $component = $this->component;
66  }
67 
69  $component,
70  $attributes['id'],
71  $attributes['class'],
72  $attributes['path'] ?? null
73  );
74  $this->mail_templates[] = $attributes['id'];
75  }
76 
77  public function endTag(string $name): void
78  {
79  if ($name === 'mailtemplates') {
80  $this->in_mailtemplates = false;
81  return;
82  }
83 
84  if ($name !== 'module' && $name !== 'service') {
85  return;
86  }
87 
88  ilMailTemplateContextService::clearFromXml($this->component, $this->mail_templates);
89  }
90 }
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i.e.
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
static insertFromXML(string $a_component, string $a_id, string $a_class, ?string $a_path)
endTag(string $name)
This is called when a tag ends in the context of the given component.
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends. ...
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
static clearFromXml(string $a_component, array $a_new_templates)