1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2016 |
6
|
|
|
* @package symfony |
7
|
|
|
* @subpackage Command |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\ShopBundle\Command; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
17
|
|
|
use Symfony\Component\DependencyInjection\Container; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Clears the content cache |
22
|
|
|
* |
23
|
|
|
* @package symfony |
24
|
|
|
* @subpackage Command |
25
|
|
|
*/ |
26
|
|
|
#[AsCommand(name: 'aimeos:clear', description: 'Clears the content cache')] |
27
|
|
|
class ClearCommand extends Command |
28
|
|
|
{ |
29
|
|
|
private $container; |
30
|
|
|
protected static $defaultName = 'aimeos:clear'; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function __construct( Container $container ) |
34
|
|
|
{ |
35
|
|
|
parent::__construct(); |
36
|
|
|
$this->container = $container; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Configures the command name and description. |
42
|
|
|
*/ |
43
|
|
|
protected function configure() |
44
|
|
|
{ |
45
|
|
|
$this->setName( self::$defaultName ); |
46
|
|
|
$this->setDescription( 'Clears the content cache' ); |
47
|
|
|
$this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)' ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Executes the job controllers. |
53
|
|
|
* |
54
|
|
|
* @param InputInterface $input Input object |
55
|
|
|
* @param OutputInterface $output Output object |
56
|
|
|
*/ |
57
|
|
|
protected function execute( InputInterface $input, OutputInterface $output ) |
58
|
|
|
{ |
59
|
|
|
$context = $this->container->get( 'aimeos.context' )->get( false, 'command' ); |
60
|
|
|
$context->setEditor( 'aimeos:clear' ); |
61
|
|
|
|
62
|
|
|
\Aimeos\MAdmin::create( $context, 'cache' )->getCache()->clear(); |
|
|
|
|
63
|
|
|
return 0; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|