vendor/symfony/doctrine-bridge/ManagerRegistry.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bridge\Doctrine;
  11. use Doctrine\Persistence\AbstractManagerRegistry;
  12. use ProxyManager\Proxy\LazyLoadingInterface;
  13. use Symfony\Component\DependencyInjection\Container;
  14. /**
  15.  * References Doctrine connections and entity/document managers.
  16.  *
  17.  * @author  Lukas Kahwe Smith <smith@pooteeweet.org>
  18.  */
  19. abstract class ManagerRegistry extends AbstractManagerRegistry
  20. {
  21.     /**
  22.      * @var Container
  23.      */
  24.     protected $container;
  25.     /**
  26.      * {@inheritdoc}
  27.      *
  28.      * @return object
  29.      */
  30.     protected function getService($name)
  31.     {
  32.         return $this->container->get($name);
  33.     }
  34.     /**
  35.      * {@inheritdoc}
  36.      *
  37.      * @return void
  38.      */
  39.     protected function resetService($name)
  40.     {
  41.         if (!$this->container->initialized($name)) {
  42.             return;
  43.         }
  44.         $manager $this->container->get($name);
  45.         if (!$manager instanceof LazyLoadingInterface) {
  46.             throw new \LogicException('Resetting a non-lazy manager service is not supported. '.(interface_exists(LazyLoadingInterface::class) ? sprintf('Declare the "%s" service as lazy.'$name) : 'Try running "composer require symfony/proxy-manager-bridge".'));
  47.         }
  48.         $manager->setProxyInitializer(\Closure::bind(
  49.             function (&$wrappedInstanceLazyLoadingInterface $manager) use ($name) {
  50.                 if (isset($this->normalizedIds[$normalizedId strtolower($name)])) { // BC with DI v3.4
  51.                     $name $this->normalizedIds[$normalizedId];
  52.                 }
  53.                 if (isset($this->aliases[$name])) {
  54.                     $name $this->aliases[$name];
  55.                 }
  56.                 if (isset($this->fileMap[$name])) {
  57.                     $wrappedInstance $this->load($this->fileMap[$name]);
  58.                 } else {
  59.                     $method $this->methodMap[$name] ?? 'get'.strtr($name$this->underscoreMap).'Service'// BC with DI v3.4
  60.                     $wrappedInstance $this->{$method}(false);
  61.                 }
  62.                 $manager->setProxyInitializer(null);
  63.                 return true;
  64.             },
  65.             $this->container,
  66.             Container::class
  67.         ));
  68.     }
  69. }