Passed
Push — master ( 48d2af...a4afe2 )
by Aimeos
11:39
created

Command   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSiteItems() 0 10 2
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package symfony
7
 * @subpackage Command
8
 */
9
10
11
namespace Aimeos\ShopBundle\Command;
12
13
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
14
use Symfony\Component\Console\Input\InputInterface;
15
16
17
18
/**
19
 * Abstract command class with common methods.
20
 *
21
 * @package symfony
22
 * @subpackage Command
23
 */
24
abstract class Command extends ContainerAwareCommand
25
{
26
	/**
27
	 * Returns the enabled site items which may be limited by the input arguments.
28
	 *
29
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
30
	 * @param InputInterface $input Input object
31
	 * @return \Aimeos\Map List of site items implementing \Aimeos\MShop\Locale\Item\Site\Interface
32
	 */
33
	protected function getSiteItems( \Aimeos\MShop\Context\Item\Iface $context, InputInterface $input ) : \Aimeos\Map
34
	{
35
		$manager = \Aimeos\MShop::create( $context, 'locale/site' );
36
		$search = $manager->createSearch();
37
38
		if( ( $codes = (string) $input->getArgument( 'site' ) ) !== '' ) {
39
			$search->setConditions( $search->compare( '==', 'locale.site.code', explode( ' ', $codes ) ) );
40
		}
41
42
		return $manager->searchItems( $search );
43
	}
44
}
45