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 ClearCommand extends AbstractCommand |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* The name and signature of the console command. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $signature = 'aimeos:clear |
29
|
|
|
{site? : Site codes to clear the Aimeos content cache for like "default unittest" (none for all)} |
30
|
|
|
'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The console command description. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $description = 'Clears the content cache'; |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Execute the console command. |
42
|
|
|
* |
43
|
|
|
* @return mixed |
44
|
|
|
*/ |
45
|
|
|
public function handle() |
46
|
|
|
{ |
47
|
|
|
$context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false, 'command' ); |
48
|
|
|
$context->setEditor( 'aimeos:clear' ); |
49
|
|
|
|
50
|
|
|
$localeManager = \Aimeos\MShop::create( $context, 'locale' ); |
51
|
|
|
|
52
|
|
|
foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem ) |
53
|
|
|
{ |
54
|
|
|
$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
|
|
|
|
55
|
|
|
|
56
|
|
|
$lcontext = clone $context; |
57
|
|
|
$lcontext->setLocale( $localeItem ); |
58
|
|
|
|
59
|
|
|
$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); |
60
|
|
|
$lcontext->setCache( $cache ); |
61
|
|
|
|
62
|
|
|
$this->info( sprintf( 'Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode() ) ); |
63
|
|
|
|
64
|
|
|
\Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|