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->aliases[$name])) {
  51.                     $name $this->aliases[$name];
  52.                 }
  53.                 if (isset($this->fileMap[$name])) {
  54.                     $wrappedInstance $this->load($this->fileMap[$name]);
  55.                 } else {
  56.                     $wrappedInstance $this->{$this->methodMap[$name]}(false);
  57.                 }
  58.                 $manager->setProxyInitializer(null);
  59.                 return true;
  60.             },
  61.             $this->container,
  62.             Container::class
  63.         ));
  64.     }
  65. }