ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilArtifactEventHandlingData.php
Go to the documentation of this file.
1 <?php
2 
20 {
21  public const EVENT_HANDLING_DATA_PATH = "./Services/EventHandling/artifacts/event_handling_data.php";
22 
23  protected array $event_handling_data;
24 
25  public function __construct()
26  {
27  $this->event_handling_data = $this->readEventHandlingData();
28  }
29 
34  protected function readEventHandlingData(): array
35  {
36  return require self::EVENT_HANDLING_DATA_PATH;
37  }
38 
42  public function hasEvent(string $component, string $type, string $type_specification): bool
43  {
44  return in_array(
45  [
46  "component" => $component,
47  "type" => $type,
48  "type_specification" => $type_specification
49  ],
50  $this->event_handling_data,
51  true
52  );
53  }
54 
59  public function getEvent(string $component, string $type, string $type_specification): array
60  {
61  if ($this->hasEvent($component, $type, $type_specification)) {
62  return [
63  "component" => $component,
64  "type" => $type,
65  "type_specification" => $type_specification
66  ];
67  }
68 
69  throw new \InvalidArgumentException(
70  "There is no event with the component \"" . $component . "\", type \"" . $type
71  . "\" and type specification \"" . $type_specification . "\"."
72  );
73  }
74 
79  public function getEventsByType(string $type): Iterator
80  {
81  foreach ($this->event_handling_data as $event_key => $event_values) {
82  if ($event_values["type"] == $type) {
83  yield $this->event_handling_data[$event_key];
84  }
85  }
86  }
87 }
getEvent(string $component, string $type, string $type_specification)
Get the event with the given component, type and type specification.
hasEvent(string $component, string $type, string $type_specification)
Check if an event exists.
readEventHandlingData()
Read the event data stored in the artifact.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getEventsByType(string $type)
Get all events of the given type.