ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilArtifactEventHandlingData.php
Go to the documentation of this file.
1<?php
2
20{
21
22 protected array $event_handling_data;
23
24 public function __construct()
25 {
26 $this->event_handling_data = $this->readEventHandlingData();
27 }
28
33 protected function readEventHandlingData(): array
34 {
35 return require ilEventHandlingBuildEventInfoObjective::PATH();
36 }
37
41 public function hasEvent(string $component, string $type, string $type_specification): bool
42 {
43 return in_array(
44 [
45 "component" => $component,
46 "type" => $type,
47 "type_specification" => $type_specification
48 ],
49 $this->event_handling_data,
50 true
51 );
52 }
53
58 public function getEvent(string $component, string $type, string $type_specification): array
59 {
60 if ($this->hasEvent($component, $type, $type_specification)) {
61 return [
62 "component" => $component,
63 "type" => $type,
64 "type_specification" => $type_specification
65 ];
66 }
67
68 throw new \InvalidArgumentException(
69 "There is no event with the component \"" . $component . "\", type \"" . $type
70 . "\" and type specification \"" . $type_specification . "\"."
71 );
72 }
73
78 public function getEventsByType(string $type): Iterator
79 {
80 foreach ($this->event_handling_data as $event_key => $event_values) {
81 if ($event_values["type"] == $type) {
82 yield $this->event_handling_data[$event_key];
83 }
84 }
85 }
86}
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.
readEventHandlingData()
Read the event data stored in the artifact.
hasEvent(string $component, string $type, string $type_specification)
Check if an event exists.
getEvent(string $component, string $type, string $type_specification)
Get the event with the given component, type and type specification.