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

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. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  15. use Symfony\Component\DependencyInjection\ContainerInterface as SymfonyContainerInterface;
  16. /**
  17.  * References Doctrine connections and entity/document managers.
  18.  *
  19.  * @author  Lukas Kahwe Smith <smith@pooteeweet.org>
  20.  */
  21. abstract class ManagerRegistry extends AbstractManagerRegistry implements ContainerAwareInterface
  22. {
  23.     /**
  24.      * @var Container
  25.      */
  26.     protected $container;
  27.     /**
  28.      * @deprecated since version 3.4, to be removed in 4.0 alongside with the ContainerAwareInterface type.
  29.      * @final since version 3.4
  30.      */
  31.     public function setContainer(SymfonyContainerInterface $container null)
  32.     {
  33.         @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.4 and will be removed in 4.0. Inject a PSR-11 container using the constructor instead.'__METHOD__), E_USER_DEPRECATED);
  34.         $this->container $container;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     protected function getService($name)
  40.     {
  41.         return $this->container->get($name);
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     protected function resetService($name)
  47.     {
  48.         if (!$this->container->initialized($name)) {
  49.             return;
  50.         }
  51.         $manager $this->container->get($name);
  52.         if (!$manager instanceof LazyLoadingInterface) {
  53.             @trigger_error(sprintf('Resetting a non-lazy manager service is deprecated since Symfony 3.2 and will throw an exception in version 4.0. Set the "%s" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.'$name), E_USER_DEPRECATED);
  54.             $this->container->set($namenull);
  55.             return;
  56.         }
  57.         $manager->setProxyInitializer(\Closure::bind(
  58.             function (&$wrappedInstanceLazyLoadingInterface $manager) use ($name) {
  59.                 if (isset($this->normalizedIds[$normalizedId strtolower($name)])) {
  60.                     $name $this->normalizedIds[$normalizedId];
  61.                 }
  62.                 if (isset($this->aliases[$name])) {
  63.                     $name $this->aliases[$name];
  64.                 }
  65.                 if (isset($this->fileMap[$name])) {
  66.                     $wrappedInstance $this->load($this->fileMap[$name]);
  67.                 } else {
  68.                     $method = !isset($this->methodMap[$name]) ? 'get'.strtr($name$this->underscoreMap).'Service' $this->methodMap[$name];
  69.                     $wrappedInstance $this->{$method}(false);
  70.                 }
  71.                 $manager->setProxyInitializer(null);
  72.                 return true;
  73.             },
  74.             $this->container,
  75.             Container::class
  76.         ));
  77.     }
  78. }