|
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\Input\InputArgument; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Clears the content cache |
|
20
|
|
|
* |
|
21
|
|
|
* @package symfony |
|
22
|
|
|
* @subpackage Command |
|
23
|
|
|
*/ |
|
24
|
|
|
class ClearCommand extends Command |
|
25
|
|
|
{ |
|
26
|
|
|
protected static $defaultName = 'aimeos:cache'; |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Configures the command name and description. |
|
31
|
|
|
*/ |
|
32
|
|
|
protected function configure() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->setName( self::$defaultName ); |
|
35
|
|
|
$this->setDescription( 'Clears the content cache' ); |
|
36
|
|
|
$this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)' ); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Executes the job controllers. |
|
42
|
|
|
* |
|
43
|
|
|
* @param InputInterface $input Input object |
|
44
|
|
|
* @param OutputInterface $output Output object |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function execute( InputInterface $input, OutputInterface $output ) |
|
47
|
|
|
{ |
|
48
|
|
|
$context = $this->getContainer()->get( 'aimeos.context' )->get( false, 'command' ); |
|
49
|
|
|
$context->setEditor( 'aimeos:clear' ); |
|
50
|
|
|
|
|
51
|
|
|
$localeManager = \Aimeos\MShop::create( $context, 'locale' ); |
|
52
|
|
|
|
|
53
|
|
|
foreach( $this->getSiteItems( $context, $input ) as $siteItem ) |
|
54
|
|
|
{ |
|
55
|
|
|
$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
$lcontext = clone $context; |
|
58
|
|
|
$lcontext->setLocale( $localeItem ); |
|
59
|
|
|
|
|
60
|
|
|
$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); |
|
61
|
|
|
$lcontext->setCache( $cache ); |
|
62
|
|
|
|
|
63
|
|
|
$output->writeln( sprintf( 'Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode() ) ); |
|
64
|
|
|
|
|
65
|
|
|
\Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|