Base::search()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Locale\Decorator;
12
13
14
/**
15
 * Base for locale frontend controller decorators
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
abstract class Base
21
	extends \Aimeos\Controller\Frontend\Base
22
	implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Locale\Iface
23
{
24
	use \Aimeos\Controller\Frontend\Common\Decorator\Traits;
25
26
27
	private \Aimeos\Controller\Frontend\Locale\Iface $controller;
28
29
30
	/**
31
	 * Initializes the controller decorator.
32
	 *
33
	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
34
	 * @param \Aimeos\MShop\ContextIface $context Context object with required objects
35
	 */
36
	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\ContextIface $context )
37
	{
38
		parent::__construct( $context );
39
40
		$this->controller = $controller;
41
	}
42
43
44
	/**
45
	 * Passes unknown methods to wrapped objects.
46
	 *
47
	 * @param string $name Name of the method
48
	 * @param array $param List of method parameter
49
	 * @return mixed Returns the value of the called method
50
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
51
	 */
52
	public function __call( string $name, array $param )
53
	{
54
		return @call_user_func_array( array( $this->controller, $name ), $param );
55
	}
56
57
58
	/**
59
	 * Clones objects in controller and resets values
60
	 */
61
	public function __clone()
62
	{
63
		$this->controller = clone $this->controller;
64
	}
65
66
67
	/**
68
	 * Adds generic condition for filtering
69
	 *
70
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
71
	 * @param string $key Search key defined by the locale manager, e.g. "locale.status"
72
	 * @param array|string $value Value or list of values to compare to
73
	 * @return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface
74
	 * @since 2019.04
75
	 */
76
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Locale\Iface
77
	{
78
		$this->controller->compare( $operator, $key, $value );
79
		return $this;
80
	}
81
82
83
	/**
84
	 * Returns the locale for the given locale ID
85
	 *
86
	 * @param string $id Unique locale ID
87
	 * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items
88
	 * @since 2019.04
89
	 */
90
	public function get( string $id ) : \Aimeos\MShop\Locale\Item\Iface
91
	{
92
		return $this->controller->get( $id );
93
	}
94
95
96
	/**
97
	 * Parses the given array and adds the conditions to the list of conditions
98
	 *
99
	 * @param array $conditions List of conditions, e.g. ['>' => ['locale.interval' => 'P0Y1M0W0D']]
100
	 * @return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface
101
	 * @since 2019.04
102
	 */
103
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Locale\Iface
104
	{
105
		$this->controller->parse( $conditions );
106
		return $this;
107
	}
108
109
110
	/**
111
	 * Returns the locales filtered by the previously assigned conditions
112
	 *
113
	 * @param int|null &$total Parameter where the total number of found locales will be stored in
114
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Locale\Item\Iface
115
	 * @since 2019.04
116
	 */
117
	public function search( ?int &$total = null ) : \Aimeos\Map
118
	{
119
		return $this->controller->search( $total );
120
	}
121
122
123
	/**
124
	 * Sets the start value and the number of returned locale items for slicing the list of found locale items
125
	 *
126
	 * @param int $start Start value of the first locale item in the list
127
	 * @param int $limit Number of returned locale items
128
	 * @return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface
129
	 * @since 2019.04
130
	 */
131
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Locale\Iface
132
	{
133
		$this->controller->slice( $start, $limit );
134
		return $this;
135
	}
136
137
138
	/**
139
	 * Sets the sorting of the result list
140
	 *
141
	 * @param string|null $key Sorting key of the result list like "interval", null for no sorting
142
	 * @return \Aimeos\Controller\Frontend\Locale\Iface Locale controller for fluent interface
143
	 * @since 2019.04
144
	 */
145
	public function sort( ?string $key = null ) : \Aimeos\Controller\Frontend\Locale\Iface
146
	{
147
		$this->controller->sort( $key );
148
		return $this;
149
	}
150
151
152
	/**
153
	 * Injects the reference of the outmost object
154
	 *
155
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
156
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
157
	 */
158
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
159
	{
160
		parent::setObject( $object );
161
162
		$this->controller->setObject( $object );
0 ignored issues
show
Bug introduced by
The method setObject() does not exist on Aimeos\Controller\Frontend\Locale\Iface. Since it exists in all sub-types, consider adding an abstract or default implementation to Aimeos\Controller\Frontend\Locale\Iface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

162
		$this->controller->/** @scrutinizer ignore-call */ 
163
                     setObject( $object );
Loading history...
163
164
		return $this;
165
	}
166
167
168
	/**
169
	 * Returns the frontend controller
170
	 *
171
	 * @return \Aimeos\Controller\Frontend\Iface Frontend controller object
172
	 */
173
	protected function getController() : \Aimeos\Controller\Frontend\Iface
174
	{
175
		return $this->controller;
176
	}
177
}
178