Completed
Push — master ( 5e44e2...ae0969 )
by Aimeos
07:40
created

Standard::createFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Locale;
12
13
14
/**
15
 * Default implementation of the locale frontend controller
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
class Standard
21
	extends \Aimeos\Controller\Frontend\Base
2 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "Base" and comma; 1 found
Loading history...
22
	implements Iface, \Aimeos\Controller\Frontend\Common\Iface
1 ignored issue
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
23
{
24
	/**
25
	 * Returns the default locale filter
26
	 *
27
	 * @param boolean True to add default criteria
28
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
29
	 * @since 2017.03
30
	 */
31
	public function createFilter()
32
	{
33
		$context = $this->getContext();
34
		$filter = \Aimeos\MShop\Factory::createManager( $context, 'locale' )->createSearch( true );
35
36
		$expr = array(
37
			$filter->compare( '==', 'locale.siteid', $context->getLocale()->getSitePath() ),
38
			$filter->getConditions(),
39
		);
40
41
		$filter->setConditions( $filter->combine( '&&', $expr ) );
42
		$filter->setSortations( array( $filter->sort( '+', 'locale.position' ) ) );
43
44
		return $filter;
45
	}
46
47
48
	/**
49
	 * Returns the locale item for the given locale ID
50
	 *
51
	 * @param string $id Unique locale ID
52
	 * @param string[] $domains Domain names of items that are associated with the locales and that should be fetched too
53
	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items
54
	 * @since 2017.03
55
	 */
56
	public function getItem( $id, array $domains = array() )
57
	{
58
		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->getItem( $id );
59
	}
60
61
62
	/**
63
	 * Returns the locales filtered by the given criteria object
64
	 *
65
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
66
	 * @param string[] $domains Domain names of items that are associated with the locales and that should be fetched too
67
	 * @param integer &$total Parameter where the total number of found locales will be stored in
68
	 * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface
69
	 * @since 2017.03
70
	 */
71
	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array(), &$total = null )
72
	{
73
		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->searchItems( $filter, [], $total );
74
	}
75
}
76