first commit
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\NullAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
abstract class AbstractPhpFileCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
private string $phpArrayFile;
|
||||
|
||||
/**
|
||||
* @param string $phpArrayFile The PHP file where metadata are cached
|
||||
*/
|
||||
public function __construct(string $phpArrayFile)
|
||||
{
|
||||
$this->phpArrayFile = $phpArrayFile;
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
|
||||
{
|
||||
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
$arrayAdapter = new ArrayAdapter();
|
||||
|
||||
spl_autoload_register([ClassExistenceResource::class, 'throwOnRequiredClass']);
|
||||
try {
|
||||
if (!$this->doWarmUp($cacheDir, $arrayAdapter, $buildDir)) {
|
||||
return [];
|
||||
}
|
||||
} finally {
|
||||
spl_autoload_unregister([ClassExistenceResource::class, 'throwOnRequiredClass']);
|
||||
}
|
||||
|
||||
// the ArrayAdapter stores the values serialized
|
||||
// to avoid mutation of the data after it was written to the cache
|
||||
// so here we un-serialize the values first
|
||||
$values = array_map(fn ($val) => null !== $val ? unserialize($val) : null, $arrayAdapter->getValues());
|
||||
|
||||
return $this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, new NullAdapter()), $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] A list of classes to preload on PHP 7.4+
|
||||
*/
|
||||
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
|
||||
{
|
||||
return (array) $phpArrayAdapter->warmUp($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final protected function ignoreAutoloadException(string $class, \Exception $exception): void
|
||||
{
|
||||
try {
|
||||
ClassExistenceResource::throwOnRequiredClass($class, $exception);
|
||||
} catch (\ReflectionException) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*
|
||||
* @return bool false if there is nothing to warm-up
|
||||
*/
|
||||
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool;
|
||||
}
|
117
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/AnnotationsCacheWarmer.php
vendored
Normal file
117
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/AnnotationsCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Doctrine\Common\Annotations\PsrCachedReader;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
|
||||
/**
|
||||
* Warms up annotation caches for classes found in composer's autoload class map
|
||||
* and declared in DI bundle extensions using the addAnnotatedClassesToCache method.
|
||||
*
|
||||
* @author Titouan Galopin <galopintitouan@gmail.com>
|
||||
*
|
||||
* @deprecated since Symfony 6.4 without replacement
|
||||
*/
|
||||
class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
{
|
||||
/**
|
||||
* @param string $phpArrayFile The PHP file where annotations are cached
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly Reader $annotationReader,
|
||||
string $phpArrayFile,
|
||||
private readonly ?string $excludeRegexp = null,
|
||||
private readonly bool $debug = false,
|
||||
/* bool $triggerDeprecation = true, */
|
||||
) {
|
||||
if (\func_num_args() < 5 || func_get_arg(4)) {
|
||||
trigger_deprecation('symfony/framework-bundle', '6.4', 'The "%s" class is deprecated without replacement.', __CLASS__);
|
||||
}
|
||||
|
||||
parent::__construct($phpArrayFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
|
||||
{
|
||||
$annotatedClassPatterns = $cacheDir.'/annotations.map';
|
||||
|
||||
if (!is_file($annotatedClassPatterns)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$annotatedClasses = include $annotatedClassPatterns;
|
||||
$reader = new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug);
|
||||
|
||||
foreach ($annotatedClasses as $class) {
|
||||
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$this->readAllComponents($reader, $class);
|
||||
} catch (\Exception $e) {
|
||||
$this->ignoreAutoloadException($class, $e);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] A list of classes to preload on PHP 7.4+
|
||||
*/
|
||||
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
|
||||
{
|
||||
// make sure we don't cache null values
|
||||
$values = array_filter($values, fn ($val) => null !== $val);
|
||||
|
||||
return parent::warmUpPhpArrayAdapter($phpArrayAdapter, $values);
|
||||
}
|
||||
|
||||
private function readAllComponents(Reader $reader, string $class): void
|
||||
{
|
||||
$reflectionClass = new \ReflectionClass($class);
|
||||
|
||||
try {
|
||||
$reader->getClassAnnotations($reflectionClass);
|
||||
} catch (AnnotationException) {
|
||||
/*
|
||||
* Ignore any AnnotationException to not break the cache warming process if an Annotation is badly
|
||||
* configured or could not be found / read / etc.
|
||||
*
|
||||
* In particular cases, an Annotation in your code can be used and defined only for a specific
|
||||
* environment but is always added to the annotations.map file by some Symfony default behaviors,
|
||||
* and you always end up with a not found Annotation.
|
||||
*/
|
||||
}
|
||||
|
||||
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
|
||||
try {
|
||||
$reader->getMethodAnnotations($reflectionMethod);
|
||||
} catch (AnnotationException) {
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
|
||||
try {
|
||||
$reader->getPropertyAnnotations($reflectionProperty);
|
||||
} catch (AnnotationException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
/**
|
||||
* Clears the cache pools when warming up the cache.
|
||||
*
|
||||
* Do not use in production!
|
||||
*
|
||||
* @author Teoh Han Hui <teohhanhui@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class CachePoolClearerCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
private Psr6CacheClearer $poolClearer;
|
||||
private array $pools;
|
||||
|
||||
/**
|
||||
* @param string[] $pools
|
||||
*/
|
||||
public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
|
||||
{
|
||||
$this->poolClearer = $poolClearer;
|
||||
$this->pools = $pools;
|
||||
}
|
||||
|
||||
public function warmUp(string $cacheDir, ?string $buildDir = null): array
|
||||
{
|
||||
foreach ($this->pools as $pool) {
|
||||
if ($this->poolClearer->hasPool($pool)) {
|
||||
$this->poolClearer->clearPool($pool);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
// optional cache warmers are not run when handling the request
|
||||
return false;
|
||||
}
|
||||
}
|
110
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/ConfigBuilderCacheWarmer.php
vendored
Normal file
110
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/ConfigBuilderCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Config\Builder\ConfigBuilderGenerator;
|
||||
use Symfony\Component\Config\Builder\ConfigBuilderGeneratorInterface;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
/**
|
||||
* Generate all config builders.
|
||||
*
|
||||
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
*/
|
||||
class ConfigBuilderCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
private KernelInterface $kernel;
|
||||
private ?LoggerInterface $logger;
|
||||
|
||||
public function __construct(KernelInterface $kernel, ?LoggerInterface $logger = null)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
|
||||
{
|
||||
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
if (!$buildDir) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$generator = new ConfigBuilderGenerator($buildDir);
|
||||
|
||||
if ($this->kernel instanceof Kernel) {
|
||||
/** @var ContainerBuilder $container */
|
||||
$container = \Closure::bind(function (Kernel $kernel) {
|
||||
$containerBuilder = $kernel->getContainerBuilder();
|
||||
$kernel->prepareContainer($containerBuilder);
|
||||
|
||||
return $containerBuilder;
|
||||
}, null, $this->kernel)($this->kernel);
|
||||
|
||||
$extensions = $container->getExtensions();
|
||||
} else {
|
||||
$extensions = [];
|
||||
foreach ($this->kernel->getBundles() as $bundle) {
|
||||
$extension = $bundle->getContainerExtension();
|
||||
if (null !== $extension) {
|
||||
$extensions[] = $extension;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($extensions as $extension) {
|
||||
try {
|
||||
$this->dumpExtension($extension, $generator);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger?->warning('Failed to generate ConfigBuilder for extension {extensionClass}: '.$e->getMessage(), ['exception' => $e, 'extensionClass' => $extension::class]);
|
||||
}
|
||||
}
|
||||
|
||||
// No need to preload anything
|
||||
return [];
|
||||
}
|
||||
|
||||
private function dumpExtension(ExtensionInterface $extension, ConfigBuilderGeneratorInterface $generator): void
|
||||
{
|
||||
$configuration = null;
|
||||
if ($extension instanceof ConfigurationInterface) {
|
||||
$configuration = $extension;
|
||||
} elseif ($extension instanceof ConfigurationExtensionInterface) {
|
||||
$container = $this->kernel->getContainer();
|
||||
$configuration = $extension->getConfiguration([], new ContainerBuilder($container instanceof Container ? new ContainerBag($container) : new ParameterBag()));
|
||||
}
|
||||
|
||||
if (!$configuration) {
|
||||
return;
|
||||
}
|
||||
|
||||
$generator->build($configuration);
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
59
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/RouterCacheWarmer.php
vendored
Normal file
59
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/RouterCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Generates the router matcher and generator classes.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
|
||||
{
|
||||
private ContainerInterface $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function warmUp(string $cacheDir, ?string $buildDir = null): array
|
||||
{
|
||||
$router = $this->container->get('router');
|
||||
|
||||
if ($router instanceof WarmableInterface) {
|
||||
return (array) $router->warmUp($cacheDir, $buildDir);
|
||||
}
|
||||
|
||||
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
return [
|
||||
'router' => RouterInterface::class,
|
||||
];
|
||||
}
|
||||
}
|
87
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/SerializerCacheWarmer.php
vendored
Normal file
87
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/SerializerCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\LoaderChain;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
||||
|
||||
/**
|
||||
* Warms up XML and YAML serializer metadata.
|
||||
*
|
||||
* @author Titouan Galopin <galopintitouan@gmail.com>
|
||||
*/
|
||||
class SerializerCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
{
|
||||
private array $loaders;
|
||||
|
||||
/**
|
||||
* @param LoaderInterface[] $loaders The serializer metadata loaders
|
||||
* @param string $phpArrayFile The PHP file where metadata are cached
|
||||
*/
|
||||
public function __construct(array $loaders, string $phpArrayFile)
|
||||
{
|
||||
parent::__construct($phpArrayFile);
|
||||
$this->loaders = $loaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
|
||||
{
|
||||
if (!$this->loaders) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$metadataFactory = new CacheClassMetadataFactory(new ClassMetadataFactory(new LoaderChain($this->loaders)), $arrayAdapter);
|
||||
|
||||
foreach ($this->extractSupportedLoaders($this->loaders) as $loader) {
|
||||
foreach ($loader->getMappedClasses() as $mappedClass) {
|
||||
try {
|
||||
$metadataFactory->getMetadataFor($mappedClass);
|
||||
} catch (AnnotationException) {
|
||||
// ignore failing annotations
|
||||
} catch (\Exception $e) {
|
||||
$this->ignoreAutoloadException($mappedClass, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoaderInterface[] $loaders
|
||||
*
|
||||
* @return XmlFileLoader[]|YamlFileLoader[]
|
||||
*/
|
||||
private function extractSupportedLoaders(array $loaders): array
|
||||
{
|
||||
$supportedLoaders = [];
|
||||
|
||||
foreach ($loaders as $loader) {
|
||||
if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) {
|
||||
$supportedLoaders[] = $loader;
|
||||
} elseif ($loader instanceof LoaderChain) {
|
||||
$supportedLoaders = array_merge($supportedLoaders, $this->extractSupportedLoaders($loader->getLoaders()));
|
||||
}
|
||||
}
|
||||
|
||||
return $supportedLoaders;
|
||||
}
|
||||
}
|
63
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/TranslationsCacheWarmer.php
vendored
Normal file
63
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/TranslationsCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Generates the catalogues for translations.
|
||||
*
|
||||
* @author Xavier Leune <xavier.leune@gmail.com>
|
||||
*/
|
||||
class TranslationsCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface
|
||||
{
|
||||
private ContainerInterface $container;
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
|
||||
{
|
||||
$this->translator ??= $this->container->get('translator');
|
||||
|
||||
if ($this->translator instanceof WarmableInterface) {
|
||||
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
|
||||
|
||||
return (array) $this->translator->warmUp($cacheDir, $buildDir);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getSubscribedServices(): array
|
||||
{
|
||||
return [
|
||||
'translator' => TranslatorInterface::class,
|
||||
];
|
||||
}
|
||||
}
|
97
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/ValidatorCacheWarmer.php
vendored
Normal file
97
plugins/simplesaml/lib/vendor/symfony/framework-bundle/CacheWarmer/ValidatorCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationException;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
|
||||
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\ValidatorBuilder;
|
||||
|
||||
/**
|
||||
* Warms up XML and YAML validator metadata.
|
||||
*
|
||||
* @author Titouan Galopin <galopintitouan@gmail.com>
|
||||
*/
|
||||
class ValidatorCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||
{
|
||||
private ValidatorBuilder $validatorBuilder;
|
||||
|
||||
/**
|
||||
* @param string $phpArrayFile The PHP file where metadata are cached
|
||||
*/
|
||||
public function __construct(ValidatorBuilder $validatorBuilder, string $phpArrayFile)
|
||||
{
|
||||
parent::__construct($phpArrayFile);
|
||||
$this->validatorBuilder = $validatorBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $buildDir
|
||||
*/
|
||||
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
|
||||
{
|
||||
$loaders = $this->validatorBuilder->getLoaders();
|
||||
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), $arrayAdapter);
|
||||
|
||||
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
|
||||
foreach ($loader->getMappedClasses() as $mappedClass) {
|
||||
try {
|
||||
if ($metadataFactory->hasMetadataFor($mappedClass)) {
|
||||
$metadataFactory->getMetadataFor($mappedClass);
|
||||
}
|
||||
} catch (AnnotationException) {
|
||||
// ignore failing annotations
|
||||
} catch (\Exception $e) {
|
||||
$this->ignoreAutoloadException($mappedClass, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] A list of classes to preload on PHP 7.4+
|
||||
*/
|
||||
protected function warmUpPhpArrayAdapter(PhpArrayAdapter $phpArrayAdapter, array $values): array
|
||||
{
|
||||
// make sure we don't cache null values
|
||||
$values = array_filter($values, fn ($val) => null !== $val);
|
||||
|
||||
return parent::warmUpPhpArrayAdapter($phpArrayAdapter, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LoaderInterface[] $loaders
|
||||
*
|
||||
* @return XmlFileLoader[]|YamlFileLoader[]
|
||||
*/
|
||||
private function extractSupportedLoaders(array $loaders): array
|
||||
{
|
||||
$supportedLoaders = [];
|
||||
|
||||
foreach ($loaders as $loader) {
|
||||
if ($loader instanceof XmlFileLoader || $loader instanceof YamlFileLoader) {
|
||||
$supportedLoaders[] = $loader;
|
||||
} elseif ($loader instanceof LoaderChain) {
|
||||
$supportedLoaders = array_merge($supportedLoaders, $this->extractSupportedLoaders($loader->getLoaders()));
|
||||
}
|
||||
}
|
||||
|
||||
return $supportedLoaders;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user