Skip to content

Commit 694cab2

Browse files
committed
Registering CacheFlushCommand
1 parent ed6da22 commit 694cab2

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/DependencyInjection/CacheExtension.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Cache\Bridge\Doctrine\DoctrineCacheBridge;
1515
use Cache\CacheBundle\Bridge\SymfonyValidatorBridge;
16+
use Cache\CacheBundle\Command\CacheFlushCommand;
1617
use Cache\CacheBundle\Factory\DoctrineBridgeFactory;
1718
use Cache\CacheBundle\Factory\RouterFactory;
1819
use Cache\CacheBundle\Factory\SessionHandlerFactory;
@@ -21,6 +22,7 @@
2122
use Cache\SessionHandler\Psr6SessionHandler;
2223
use Symfony\Component\Config\FileLocator;
2324
use Symfony\Component\DependencyInjection\ContainerBuilder;
25+
use Symfony\Component\DependencyInjection\Definition;
2426
use Symfony\Component\DependencyInjection\Loader;
2527
use Symfony\Component\DependencyInjection\Reference;
2628
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -69,6 +71,9 @@ public function load(array $configs, ContainerBuilder $container)
6971
$serviceIds = [];
7072
$this->findServiceIds($config, $serviceIds);
7173
$container->setParameter('cache.provider_service_ids', $serviceIds);
74+
75+
$container->register(CacheFlushCommand::class, CacheFlushCommand::class)
76+
->addTag('console.command', ['command' => 'cache:flush']);
7277
}
7378

7479
/**
@@ -98,10 +103,12 @@ protected function findServiceIds(array $config, array &$serviceIds)
98103
private function verifyDoctrineBridgeExists($name)
99104
{
100105
if (!class_exists('Cache\Bridge\Doctrine\DoctrineCacheBridge')) {
101-
throw new \Exception(sprintf(
102-
'You need the DoctrineCacheBridge to be able to use "%s". Please run "composer require cache/psr-6-doctrine-bridge" to install the missing dependency.',
103-
$name
104-
));
106+
throw new \Exception(
107+
sprintf(
108+
'You need the DoctrineCacheBridge to be able to use "%s". Please run "composer require cache/psr-6-doctrine-bridge" to install the missing dependency.',
109+
$name
110+
)
111+
);
105112
}
106113
}
107114

@@ -117,7 +124,7 @@ public function getAlias()
117124
* Register services. All service ids will start witn "cache.service.".
118125
*
119126
* @param ContainerBuilder $container
120-
* @param $config
127+
* @param $config
121128
*
122129
* @throws \Exception
123130
*/

0 commit comments

Comments
 (0)