mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +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:
@@ -11,10 +11,12 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\Dumper\Preloader;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
|
||||
|
||||
/**
|
||||
@@ -22,27 +24,17 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since version 3.4
|
||||
* @final
|
||||
*/
|
||||
class CacheWarmupCommand extends ContainerAwareCommand
|
||||
class CacheWarmupCommand extends Command
|
||||
{
|
||||
protected static $defaultName = 'cache:warmup';
|
||||
protected static $defaultDescription = 'Warm up an empty cache';
|
||||
|
||||
private $cacheWarmer;
|
||||
|
||||
/**
|
||||
* @param CacheWarmerAggregate $cacheWarmer
|
||||
*/
|
||||
public function __construct($cacheWarmer = null)
|
||||
public function __construct(CacheWarmerAggregate $cacheWarmer)
|
||||
{
|
||||
if (!$cacheWarmer instanceof CacheWarmerAggregate) {
|
||||
@trigger_error(sprintf('Passing a command name as the first argument of "%s()" is deprecated since Symfony 3.4 and support for it will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), \E_USER_DEPRECATED);
|
||||
|
||||
parent::__construct($cacheWarmer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->cacheWarmer = $cacheWarmer;
|
||||
@@ -57,7 +49,7 @@ class CacheWarmupCommand extends ContainerAwareCommand
|
||||
->setDefinition([
|
||||
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
||||
])
|
||||
->setDescription('Warms up an empty cache')
|
||||
->setDescription(self::$defaultDescription)
|
||||
->setHelp(<<<'EOF'
|
||||
The <info>%command.name%</info> command warms up the cache.
|
||||
|
||||
@@ -76,14 +68,8 @@ EOF
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// BC to be removed in 4.0
|
||||
if (null === $this->cacheWarmer) {
|
||||
$this->cacheWarmer = $this->getContainer()->get('cache_warmer');
|
||||
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||
}
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$kernel = $this->getApplication()->getKernel();
|
||||
@@ -93,8 +79,14 @@ EOF
|
||||
$this->cacheWarmer->enableOptionalWarmers();
|
||||
}
|
||||
|
||||
$this->cacheWarmer->warmUp(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'));
|
||||
$preload = $this->cacheWarmer->warmUp($cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'));
|
||||
|
||||
if ($preload && file_exists($preloadFile = $cacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
|
||||
Preloader::append($preloadFile, $preload);
|
||||
}
|
||||
|
||||
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user