Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -21,6 +21,13 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
*/
class ClassCacheCacheWarmer implements CacheWarmerInterface
{
private $declaredClasses;
public function __construct(array $declaredClasses = null)
{
$this->declaredClasses = $declaredClasses;
}
/**
* Warms up the cache.
*
@@ -37,8 +44,9 @@ class ClassCacheCacheWarmer implements CacheWarmerInterface
if (file_exists($cacheDir.'/classes.php')) {
return;
}
$declared = null !== $this->declaredClasses ? $this->declaredClasses : array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false);
ClassCollectionLoader::inline(include($classmap), $cacheDir.'/classes.php', $declared);
}
/**
@@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Templating\TemplateNameParserInterface;
use Symfony\Component\Templating\TemplateReferenceInterface;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
/**
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
@@ -43,13 +44,16 @@ class TemplatePathsCacheWarmer extends CacheWarmer
*/
public function warmUp($cacheDir)
{
$filesystem = new Filesystem();
$templates = array();
foreach ($this->finder->findAllTemplates() as $template) {
$templates[$template->getLogicalName()] = $this->locator->locate($template);
$templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
}
$this->writeCacheFile($cacheDir.'/templates.php', sprintf('<?php return %s;', var_export($templates, true)));
$templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
$this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
}
/**
@@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Translation\TranslatorInterface;
@@ -22,11 +23,24 @@ use Symfony\Component\Translation\TranslatorInterface;
*/
class TranslationsCacheWarmer implements CacheWarmerInterface
{
private $container;
private $translator;
public function __construct(TranslatorInterface $translator)
/**
* TranslationsCacheWarmer constructor.
*
* @param ContainerInterface|TranslatorInterface $container
*/
public function __construct($container)
{
$this->translator = $translator;
// As this cache warmer is optional, dependencies should be lazy-loaded, that's why a container should be injected.
if ($container instanceof ContainerInterface) {
$this->container = $container;
} elseif ($container instanceof TranslatorInterface) {
$this->translator = $container;
} else {
throw new \InvalidArgumentException(sprintf('%s only accepts instance of Symfony\Component\DependencyInjection\ContainerInterface or Symfony\Component\Translation\TranslatorInterface as first argument.', __CLASS__));
}
}
/**
@@ -34,6 +48,10 @@ class TranslationsCacheWarmer implements CacheWarmerInterface
*/
public function warmUp($cacheDir)
{
if (null === $this->translator) {
$this->translator = $this->container->get('translator');
}
if ($this->translator instanceof WarmableInterface) {
$this->translator->warmUp($cacheDir);
}