Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     if (!method_exists($this->validatorBuilder, 'getLoaders')) {
         return;
     }
     $adapter = new PhpArrayAdapter($this->phpArrayFile, $this->fallbackPool);
     $arrayPool = new ArrayAdapter(0, false);
     $loaders = $this->validatorBuilder->getLoaders();
     $metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayPool));
     $throwingAutoloader = function ($class) {
         throw new \ReflectionException(sprintf('Class %s does not exist', $class));
     };
     spl_autoload_register($throwingAutoloader);
     try {
         foreach ($this->extractSupportedLoaders($loaders) as $loader) {
             foreach ($loader->getMappedClasses() as $mappedClass) {
                 try {
                     if ($metadataFactory->hasMetadataFor($mappedClass)) {
                         $metadataFactory->getMetadataFor($mappedClass);
                     }
                 } catch (\ReflectionException $e) {
                     // ignore failing reflection
                 }
             }
         }
     } finally {
         spl_autoload_unregister($throwingAutoloader);
     }
     $values = $arrayPool->getValues();
     $adapter->warmUp($values);
     foreach ($values as $k => $v) {
         $item = $this->fallbackPool->getItem($k);
         $this->fallbackPool->saveDeferred($item->set($v));
     }
     $this->fallbackPool->commit();
 }
 /**
  * {@inheritdoc}
  */
 public function warmUp($cacheDir)
 {
     if (!method_exists($this->validatorBuilder, 'getLoaders')) {
         return;
     }
     $adapter = new PhpArrayAdapter($this->phpArrayFile, $this->fallbackPool);
     $arrayPool = new ArrayAdapter(0, false);
     $loaders = $this->validatorBuilder->getLoaders();
     $metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayPool));
     foreach ($this->extractSupportedLoaders($loaders) as $loader) {
         foreach ($loader->getMappedClasses() as $mappedClass) {
             if ($metadataFactory->hasMetadataFor($mappedClass)) {
                 $metadataFactory->getMetadataFor($mappedClass);
             }
         }
     }
     $values = $arrayPool->getValues();
     $adapter->warmUp($values);
     foreach ($values as $k => $v) {
         $item = $this->fallbackPool->getItem($k);
         $this->fallbackPool->saveDeferred($item->set($v));
     }
     $this->fallbackPool->commit();
 }