You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #23624 [FrameworkBundle] Commands as a service (ro0NL)
This PR was squashed before being merged into the 3.4 branch (closes #23624).
Discussion
----------
[FrameworkBundle] Commands as a service
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes/no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->
Next step towards #23488
It's a work in progress if we want to do all commands at once (im fine :)). But i think we should review `assets:install` first.
Also im assuming framework commands can rely on `getApplication()->getKernel()` from the framework application (we already do that in some commands). That saves a dep on `@kernel`.
And filesystem as a service; perhaps drop that as well :)
Commits
-------
de1dc0b [FrameworkBundle] Commands as a service
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
if (!$cacheClearerinstanceof CacheClearerInterface) {
45
+
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
thrownew \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
67
101
}
68
102
69
-
if ($filesystem->exists($oldCacheDir)) {
70
-
$filesystem->remove($oldCacheDir);
103
+
if ($this->filesystem->exists($oldCacheDir)) {
104
+
$this->filesystem->remove($oldCacheDir);
71
105
}
72
106
73
-
$kernel = $this->getContainer()->get('kernel');
74
107
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$warning = 'Calling cache:clear without the --no-warmup option is deprecated since version 3.3. Cache warmup should be done with the cache:warmup command instead.';
81
114
@@ -90,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
90
123
$io->comment('Removing old cache directory...');
91
124
}
92
125
93
-
$filesystem->remove($oldCacheDir);
126
+
$this->filesystem->remove($oldCacheDir);
94
127
95
128
if ($output->isVerbose()) {
96
129
$io->comment('Finished');
@@ -101,31 +134,30 @@ protected function execute(InputInterface $input, OutputInterface $output)
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
class CacheWarmupCommand extends ContainerAwareCommand
25
28
{
29
+
private$cacheWarmer;
30
+
31
+
/**
32
+
* @param CacheWarmerAggregate $cacheWarmer
33
+
*/
34
+
publicfunction__construct($cacheWarmer = null)
35
+
{
36
+
parent::__construct();
37
+
38
+
if (!$cacheWarmerinstanceof CacheWarmerAggregate) {
39
+
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
0 commit comments