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

Command::getSiteItems()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
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