19declare(strict_types=1);
63 $this->db =
$DIC->database();
64 $this->component_repository =
$DIC[
"component.repository"];
65 $this->component_factory =
$DIC[
"component.factory"];
74 $cached_listeners = $ilGlobalCache->get(
'listeners');
75 if (is_array($cached_listeners)) {
76 $this->listener = $cached_listeners;
83 $this->listener = array();
85 $sql =
"SELECT * FROM il_event_handling" .
86 " WHERE type = " .
$ilDB->quote(
"listen",
"text");
89 $this->listener[$row[
"id"]][] = $row[
"component"];
92 $ilGlobalCache->set(
'listeners', $this->listener);
102 public function raise(
105 array $a_parameter = []
107 $this->
logger->debug(sprintf(
108 "Received event '%s' from component '%s'.",
113 $parameter_formatter =
static function ($value) use (&$parameter_formatter) {
114 if (is_object($value)) {
115 return get_class($value);
118 if (is_array($value)) {
120 $parameter_formatter,
128 $this->
logger->debug(
'Event data: ' . var_export(array_map(
129 $parameter_formatter,
133 $this->
logger->debug(
"Started event propagation for event listeners ...");
135 if (is_array($this->listener[$a_component] ??
null)) {
136 foreach ($this->listener[$a_component] as
$listener) {
139 $comp = substr(
$listener, 0, $last_slash);
142 if ($comp ==
'Plugins') {
146 foreach ($this->component_repository->getPlugins() as $pl) {
147 if ($pl->getName() !==
$name || !$pl->isActive()) {
150 $plugin = $this->component_factory->getPlugin($pl->getId());
151 $plugin->handleEvent($a_component, $a_event, $a_parameter);
154 $class =
'il' . substr(
$listener, $last_slash + 1) .
'AppEventListener';
155 $file =
"./" .
$listener .
"/classes/class." . $class .
".php";
157 if (is_file($file)) {
159 call_user_func(array($class,
'handleEvent'), $a_component, $a_event, $a_parameter);
165 $this->
logger->debug(
"Finished event listener handling, started event propagation for event hook plugins ...");
168 foreach ($this->component_factory->getActivePluginsInSlot(
"evhk") as
$plugin) {
169 $plugin->handleEvent($a_component, $a_event, $a_parameter);
ilComponentFactory $component_factory
ilComponentRepository $component_repository
static getInstance(?string $component)
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
Readable part of repository interface to ilComponentDataDB.