Completed
Push — master ( aa9489...67c4a6 )
by Aimeos
02:16
created

src/Aimeos/Shop/Command/CacheCommand.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 name and signature of the console command.
25
	 *
26
	 * @var string
27
	 */
28
	protected $signature = 'aimeos:cache
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:cache' );
49
50
		$localeManager = \Aimeos\MShop::create( $context, 'locale' );
51
52
		foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem )
0 ignored issues
show
It seems like $this->argument('site') targeting Illuminate\Console\Command::argument() can also be of type null; however, Aimeos\Shop\Command\Abst...Command::getSiteItems() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
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