|
11 | 11 |
|
12 | 12 | namespace Symfony\Bundle\FrameworkBundle\Controller;
|
13 | 13 |
|
14 |
| -use Doctrine\Common\Persistence\ManagerRegistry; |
| 14 | +use Doctrine\Common\Persistence\ManagerRegistry as LegacyManagerRegistry; |
| 15 | +use Doctrine\Persistence\ManagerRegistry; |
15 | 16 | use Psr\Container\ContainerInterface;
|
16 | 17 | use Psr\Link\LinkInterface;
|
17 | 18 | use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
@@ -94,7 +95,7 @@ public static function getSubscribedServices()
|
94 | 95 | 'session' => '?'.SessionInterface::class,
|
95 | 96 | 'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class,
|
96 | 97 | 'twig' => '?'.Environment::class,
|
97 |
| - 'doctrine' => '?'.ManagerRegistry::class, |
| 98 | + 'doctrine' => '?'.(interface_exists(ManagerRegistry::class) ? ManagerRegistry::class : LegacyManagerRegistry::class), |
98 | 99 | 'form.factory' => '?'.FormFactoryInterface::class,
|
99 | 100 | 'security.token_storage' => '?'.TokenStorageInterface::class,
|
100 | 101 | 'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
|
@@ -337,9 +338,11 @@ protected function createFormBuilder($data = null, array $options = []): FormBui
|
337 | 338 | /**
|
338 | 339 | * Shortcut to return the Doctrine Registry service.
|
339 | 340 | *
|
| 341 | + * @return ManagerRegistry|LegacyManagerRegistry |
| 342 | + * |
340 | 343 | * @throws \LogicException If DoctrineBundle is not available
|
341 | 344 | */
|
342 |
| - protected function getDoctrine(): ManagerRegistry |
| 345 | + protected function getDoctrine() |
343 | 346 | {
|
344 | 347 | if (!$this->container->has('doctrine')) {
|
345 | 348 | throw new \LogicException('The DoctrineBundle is not registered in your application. Try running "composer require symfony/orm-pack".');
|
|
0 commit comments