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\Common\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.     protected function getService($name)
  29.     {
  30.         return $this->container->get($name);
  31.     }
  32.     /**
  33.      * {@inheritdoc}
  34.      */
  35.     protected function resetService($name)
  36.     {
  37.         if (!$this->container->initialized($name)) {
  38.             return;
  39.         }
  40.         $manager $this->container->get($name);
  41.         if (!$manager instanceof LazyLoadingInterface) {
  42.             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".'));
  43.         }
  44.         $manager->setProxyInitializer(\Closure::bind(
  45.             function (&$wrappedInstanceLazyLoadingInterface $manager) use ($name) {
  46.                 if (isset($this->normalizedIds[$normalizedId strtolower($name)])) { // BC with DI v3.4
  47.                     $name $this->normalizedIds[$normalizedId];
  48.                 }
  49.                 if (isset($this->aliases[$name])) {
  50.                     $name $this->aliases[$name];
  51.                 }
  52.                 if (isset($this->fileMap[$name])) {
  53.                     $wrappedInstance $this->load($this->fileMap[$name]);
  54.                 } else {
  55.                     $method $this->methodMap[$name] ?? 'get'.strtr($name$this->underscoreMap).'Service'// BC with DI v3.4
  56.                     $wrappedInstance $this->{$method}(false);
  57.                 }
  58.                 $manager->setProxyInitializer(null);
  59.                 return true;
  60.             },
  61.             $this->container,
  62.             Container::class
  63.         ));
  64.     }
  65. }