-
Notifications
You must be signed in to change notification settings - Fork 1k
/
ClearCommand.php
67 lines (52 loc) · 1.51 KB
/
ClearCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* @license MIT, http://opensource.org/licenses/MIT
* @copyright Aimeos (aimeos.org), 2015-2016
* @package laravel
* @subpackage Command
*/
namespace Aimeos\Shop\Command;
use Symfony\Component\Console\Input\InputArgument;
/**
* Command for clearing the content cache
* @package laravel
* @subpackage Command
*/
class ClearCommand extends AbstractCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'aimeos:clear
{site? : Site codes to clear the Aimeos content cache for like "default unittest" (none for all)}
';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clears the content cache';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false, 'command' );
$context->setEditor( 'aimeos:clear' );
$localeManager = \Aimeos\MShop::create( $context, 'locale' );
foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem )
{
$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false );
$lcontext = clone $context;
$lcontext->setLocale( $localeItem );
$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext );
$lcontext->setCache( $cache );
$this->info( sprintf( 'Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode() ) );
\Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear();
}
}
}