Completed
Push — master ( 2507d2...3b83d2 )
by Aimeos
03:49
created

Sites::setView()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 2
eloc 10
nc 2
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Common\Decorator;
12
13
14
/**
15
 * Sites decorator for JQAdm clients
16
 *
17
 * @package Admin
18
 * @subpackage JQAdm
19
 */
20
class Sites extends Base
21
{
22
	/**
23
	 * Sets the view object and adds the available sites
24
	 *
25
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output
26
	 * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
27
	 */
28
	public function setView( \Aimeos\MW\View\Iface $view )
29
	{
30
		$list = array();
31
		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale/site' );
32
33
		$search = $manager->createSearch();
34
		$search->setSortations( array( $search->sort( '+', 'locale.site.label' ) ) );
35
36
		foreach( $manager->searchItems( $search ) as $item ) {
37
			$list[$item->getCode()] = $item->getLabel();
38
		}
39
40
		$view->sitesList = $list;
41
42
		$this->getClient()->setView( $view );
43
		return $this;
44
	}
45
}
46