Completed
Push — master ( 22fee6...a6e7a8 )
by Aimeos
02:32
created

Support   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGroups() 0 14 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 Service
8
 */
9
10
namespace Aimeos\ShopBundle\Service;
11
12
use Symfony\Component\HttpFoundation\RequestStack;
13
use Symfony\Component\DependencyInjection\Container;
14
15
16
/**
17
 * Service providing the support objects
18
 *
19
 * @package symfony
20
 * @subpackage Service
21
 */
22
class Support
23
{
24
	/**
25
	 * Returns the closure for retrieving the user groups
26
	 *
27
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
28
	 * @return array List of group codes the user is in
29
	 */
30
	public function getGroups( \Aimeos\MShop\Context\Item\Iface $context )
31
	{
32
		$list = array();
33
		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/group' );
34
35
		$search = $manager->createSearch();
36
		$search->setConditions( $search->compare( '==', 'customer.group.id', $context->getGroupIds() ) );
37
38
		foreach( $manager->searchItems( $search ) as $item ) {
39
			$list[] = $item->getCode();
40
		}
41
42
		return $list;
43
	}
44
}
45