1 | <?php |
||
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() |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Get the console command options. |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | protected function getOptions() |
||
89 | } |
||
90 |