1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package laravel |
7
|
|
|
* @subpackage Command |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Shop\Command; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Command for clearing the content cache |
18
|
|
|
* @package laravel |
19
|
|
|
* @subpackage Command |
20
|
|
|
*/ |
21
|
|
|
class CacheCommand extends AbstractCommand |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* The console command name. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $name = 'aimeos:cache'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The console command description. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $description = 'Clears the content cache'; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Execute the console command. |
40
|
|
|
* |
41
|
|
|
* @return mixed |
42
|
|
|
*/ |
43
|
|
|
public function handle() |
44
|
|
|
{ |
45
|
|
|
$context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false, 'command' ); |
46
|
|
|
$context->setEditor( 'aimeos:cache' ); |
47
|
|
|
|
48
|
|
|
$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
49
|
|
|
|
50
|
|
|
foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem ) |
51
|
|
|
{ |
52
|
|
|
$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
53
|
|
|
|
54
|
|
|
$lcontext = clone $context; |
55
|
|
|
$lcontext->setLocale( $localeItem ); |
56
|
|
|
|
57
|
|
|
$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); |
58
|
|
|
$lcontext->setCache( $cache ); |
59
|
|
|
|
60
|
|
|
$this->info( sprintf( 'Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode() ) ); |
61
|
|
|
|
62
|
|
|
\Aimeos\MAdmin\Cache\Manager\Factory::createManager( $lcontext )->getCache()->clear(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get the console command arguments. |
69
|
|
|
* |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
protected function getArguments() |
73
|
|
|
{ |
74
|
|
|
return array( |
75
|
|
|
array( 'site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)' ), |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Get the console command options. |
82
|
|
|
* |
83
|
|
|
* @return array |
84
|
|
|
*/ |
85
|
|
|
protected function getOptions() |
86
|
|
|
{ |
87
|
|
|
return array(); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|