vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/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 ProxyManager\Proxy\LazyLoadingInterface;
  12. use Symfony\Component\DependencyInjection\Container;
  13. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  14. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  15. use Doctrine\Common\Persistence\AbstractManagerRegistry;
  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.     use ContainerAwareTrait;
  24.     /**
  25.      * {@inheritdoc}
  26.      */
  27.     protected function getService($name)
  28.     {
  29.         return $this->container->get($name);
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      */
  34.     protected function resetService($name)
  35.     {
  36.         if (!$this->container->initialized($name)) {
  37.             return;
  38.         }
  39.         $manager $this->container->get($name);
  40.         if (!$manager instanceof LazyLoadingInterface) {
  41.             @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);
  42.             $this->container->set($namenull);
  43.             return;
  44.         }
  45.         $manager->setProxyInitializer(\Closure::bind(
  46.             function (&$wrappedInstanceLazyLoadingInterface $manager) use ($name) {
  47.                 if (isset($this->normalizedIds[$normalizedId strtolower($name)])) {
  48.                     $name $this->normalizedIds[$normalizedId];
  49.                 }
  50.                 if (isset($this->aliases[$name])) {
  51.                     $name $this->aliases[$name];
  52.                 }
  53.                 $method = !isset($this->methodMap[$name]) ? 'get'.strtr($name$this->underscoreMap).'Service' $this->methodMap[$name];
  54.                 $wrappedInstance $this->{$method}(false);
  55.                 $manager->setProxyInitializer(null);
  56.                 return true;
  57.             },
  58.             $this->container,
  59.             Container::class
  60.         ));
  61.     }
  62. }