bug #37056 [DoctrineBridge] register event listeners depending on the installed packages (xabbuh)

This PR was merged into the 5.1 branch.

Discussion
----------

[DoctrineBridge] register event listeners depending on the installed packages

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37045
| License       | MIT
| Doc PR        |

Commits
-------

f61b0097f4 register event listeners depending on the installed packages
This commit is contained in:
Fabien Potencier 2020-06-02 10:47:59 +02:00
commit 706ff581fb
2 changed files with 15 additions and 4 deletions

View File

@ -89,9 +89,16 @@ final class MessengerTransportDoctrineSchemaSubscriber implements EventSubscribe
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;
}
}

View File

@ -43,6 +43,10 @@ final class PdoCacheAdapterDoctrineSchemaSubscriber implements EventSubscriber
public function getSubscribedEvents(): array
{
if (!class_exists(ToolEvents::class)) {
return [];
}
return [
ToolEvents::postGenerateSchema,
];