Skip to content

Commit

Permalink
register event listeners depending on the installed packages
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jun 2, 2020
1 parent e5b5d9e commit f61b009
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -89,9 +89,16 @@ public function onSchemaCreateTable(SchemaCreateTableEventArgs $event): void

public function getSubscribedEvents(): array
{
return [
ToolEvents::postGenerateSchema,
Events::onSchemaCreateTable,
];
$subscribedEvents = [];

if (class_exists(ToolEvents::class)) {
$subscribedEvents[] = ToolEvents::postGenerateSchema;
}

if (class_exists(Events::class)) {
$subscribedEvents[] = Events::onSchemaCreateTable;
}

return $subscribedEvents;
}
}
Expand Up @@ -43,6 +43,10 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void

public function getSubscribedEvents(): array
{
if (!class_exists(ToolEvents::class)) {
return [];
}

return [
ToolEvents::postGenerateSchema,
];
Expand Down

0 comments on commit f61b009

Please sign in to comment.