mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -12,16 +12,14 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
use Symfony\Component\Validator\Mapping\Cache\Psr6Cache;
|
||||
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory;
|
||||
use Symfony\Component\Validator\Mapping\Loader\LoaderChain;
|
||||
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
|
||||
use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Validator\ValidatorBuilderInterface;
|
||||
use Symfony\Component\Validator\ValidatorBuilder;
|
||||
|
||||
/**
|
||||
* Warms up XML and YAML validator metadata.
|
||||
@@ -33,26 +31,25 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
private $validatorBuilder;
|
||||
|
||||
/**
|
||||
* @param string $phpArrayFile The PHP file where metadata are cached
|
||||
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered metadata are cached
|
||||
* @param string $phpArrayFile The PHP file where metadata are cached
|
||||
*/
|
||||
public function __construct(ValidatorBuilderInterface $validatorBuilder, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
|
||||
public function __construct(ValidatorBuilder $validatorBuilder, string $phpArrayFile)
|
||||
{
|
||||
parent::__construct($phpArrayFile, $fallbackPool);
|
||||
parent::__construct($phpArrayFile);
|
||||
$this->validatorBuilder = $validatorBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
|
||||
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
|
||||
{
|
||||
if (!method_exists($this->validatorBuilder, 'getLoaders')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$loaders = $this->validatorBuilder->getLoaders();
|
||||
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayAdapter));
|
||||
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), $arrayAdapter);
|
||||
|
||||
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
|
||||
foreach ($loader->getMappedClasses() as $mappedClass) {
|
||||
@@ -71,10 +68,15 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] A list of classes to preload on PHP 7.4+
|
||||
*/
|
||||
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values)
|
||||
{
|
||||
// make sure we don't cache null values
|
||||
parent::warmUpPhpArrayAdapter($phpArrayAdapter, array_filter($values));
|
||||
$values = array_filter($values, function ($val) { return null !== $val; });
|
||||
|
||||
return parent::warmUpPhpArrayAdapter($phpArrayAdapter, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +84,7 @@ class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
*
|
||||
* @return XmlFileLoader[]|YamlFileLoader[]
|
||||
*/
|
||||
private function extractSupportedLoaders(array $loaders)
|
||||
private function extractSupportedLoaders(array $loaders): array
|
||||
{
|
||||
$supportedLoaders = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user