ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilEventHandlingDefinitionProcessor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 protected array $data = [];
27 protected ?string $component;
28
29 public function getData(): array
30 {
31 return $this->data;
32 }
33
34 public function purge(): void
35 {
36 $this->data = [];
37 }
38
39 public function beginComponent(string $component, string $type): void
40 {
41 $this->component = $type . "/" . $component;
42 }
43
44 public function endComponent(string $component, string $type): void
45 {
46 $this->component = null;
47 }
48
49 public function beginTag(string $name, array $attributes): void
50 {
51 if ($name !== "event") {
52 return;
53 }
54
55 $component = $attributes["component"] ?? null;
56 if (!$component) {
58 }
59
60 $event = [
61 "component" => $component,
62 "type" => $attributes["type"],
63 "type_specification" => $attributes["id"]
64 ];
65
66 // only add event to data if no such entry exists
67 if (!$this->hasDataEntryForEvent($event)) {
68 $this->data[] = $event;
69 }
70 }
71
72 public function endTag(string $name): void
73 {
74 }
75
76 public function hasDataEntryForEvent($event): bool
77 {
78 return in_array($event, $this->data, true);
79 }
80}
endComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component ends.
beginComponent(string $component, string $type)
This method is called when parsing of component.xml for the given component starts.
endTag(string $name)
This is called when a tag ends in the context of the given component.
purge()
This methods is supposed to purge existing data in the provider of the component, so new components c...
beginTag(string $name, array $attributes)
This is called when a tag starts in the context of the given component.
An ilComponentDefinitionProcessor processes some attributes from a component.xml (i....