Created
March 25, 2020 16:05
-
-
Save htuscher/147c26ce712c99a5147e4f0ee03f0691 to your computer and use it in GitHub Desktop.
Override Symfony clear cache command for Shopware6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
/*************************************************************** | |
* Copyright notice | |
* | |
* (c) 2020 Hans Hoechtl <[email protected]> | |
* All rights reserved | |
***************************************************************/ | |
namespace Onedrop\Platform\Command; | |
use Shopware\Core\Framework\Adapter\Cache\CacheClearer; | |
use Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Filesystem\Filesystem; | |
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; | |
class ClearCacheCommand extends CacheClearCommand | |
{ | |
protected static $defaultName = 'cache:clear'; | |
/** | |
* @var CacheClearer | |
*/ | |
private $shopwareCacheClearer; | |
/** | |
* ClearCacheCommand constructor. | |
* | |
* @param CacheClearer $cacheClearer | |
* @param CacheClearerInterface $cacheClearer | |
* @param Filesystem|null $filesystem | |
*/ | |
public function __construct(CacheClearer $shopwareCacheClearer, CacheClearerInterface $cacheClearer, Filesystem $filesystem = null) | |
{ | |
$this->shopwareCacheClearer = $shopwareCacheClearer; | |
parent::__construct($cacheClearer, $filesystem); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output): int | |
{ | |
$this->shopwareCacheClearer->clear(); | |
return parent::execute($input, $output); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
Onedrop\Platform\Command\ClearCacheCommand: | |
arguments: | |
- '@Shopware\Core\Framework\Adapter\Cache\CacheClearer' | |
- '@cache_clearer' | |
- '@filesystem' | |
tags: | |
- {name: 'console.command', command: 'cache:clear'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment