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

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