/**
  * {@inheritDoc}
  */
 public function boot()
 {
     // Register an autoloader for proxies to avoid issues when unserializing them
     // when the ORM is used.
     if ($this->container->hasParameter('doctrine.orm.proxy_namespace')) {
         $namespace = $this->container->getParameter('doctrine.orm.proxy_namespace');
         $dir = $this->container->getParameter('doctrine.orm.proxy_dir');
         $proxyGenerator = null;
         if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes')) {
             // See https://github.com/symfony/symfony/pull/3419 for usage of references
             $container =& $this->container;
             $proxyGenerator = function ($proxyDir, $proxyNamespace, $class) use(&$container) {
                 $originalClassName = ClassUtils::getRealClass($class);
                 /** @var $registry Registry */
                 $registry = $container->get('doctrine');
                 // Tries to auto-generate the proxy file
                 /** @var $em \Doctrine\ORM\EntityManager */
                 foreach ($registry->getManagers() as $em) {
                     if (!$em->getConfiguration()->getAutoGenerateProxyClasses()) {
                         continue;
                     }
                     $metadataFactory = $em->getMetadataFactory();
                     if ($metadataFactory->isTransient($originalClassName)) {
                         continue;
                     }
                     $classMetadata = $metadataFactory->getMetadataFor($originalClassName);
                     $em->getProxyFactory()->generateProxyClasses(array($classMetadata));
                     clearstatcache(true, Autoloader::resolveFile($proxyDir, $proxyNamespace, $class));
                     break;
                 }
             };
         }
         $this->autoloader = Autoloader::register($dir, $namespace, $proxyGenerator);
     }
 }
 /**
  * @dataProvider dataResolveFile
  */
 public function testResolveFile($proxyDir, $proxyNamespace, $className, $expectedProxyFile)
 {
     $actualProxyFile = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className);
     $this->assertEquals($expectedProxyFile, $actualProxyFile);
 }