Base::slice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021-2025
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Site\Decorator;
12
13
14
/**
15
 * Base for site 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\Site\Iface
23
{
24
	use \Aimeos\Controller\Frontend\Common\Decorator\Traits;
25
26
27
	private \Aimeos\Controller\Frontend\Site\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 attributes
69
	 *
70
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
71
	 * @param string $key Search key defined by the site manager, e.g. "site.status"
72
	 * @param array|string $value Value or list of values to compare to
73
	 * @return \Aimeos\Controller\Frontend\Site\Iface Site controller for fluent interface
74
	 * @since 2021.04
75
	 */
76
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Site\Iface
77
	{
78
		$this->controller->compare( $operator, $key, $value );
79
		return $this;
80
	}
81
82
83
	/**
84
	 * Returns the category for the given site code
85
	 *
86
	 * @param string $code Unique site code
87
	 * @return \Aimeos\MShop\Locale\Item\Site\Iface Site item
88
	 * @since 2021.04
89
	 */
90
	public function find( string $code ) : \Aimeos\MShop\Locale\Item\Site\Iface
91
	{
92
		return $this->controller->find( $code );
93
	}
94
95
96
	/**
97
	 * Returns the category for the given site ID
98
	 *
99
	 * @param string $id Unique site ID
100
	 * @return \Aimeos\MShop\Locale\Item\Site\Iface Site item
101
	 * @since 2021.04
102
	 */
103
	public function get( string $id ) : \Aimeos\MShop\Locale\Item\Site\Iface
104
	{
105
		return $this->controller->get( $id );
106
	}
107
108
109
	/**
110
	 * Returns the list of sites up to the root node including the node given by its ID
111
	 *
112
	 * @param string $id Current category ID
113
	 * @return \Aimeos\MShop\Locale\Item\Site\Iface[] Associative list of sites
114
	 * @since 2021.04
115
	 */
116
	public function getPath( string $id )
117
	{
118
		return $this->controller->getPath( $id );
119
	}
120
121
122
	/**
123
	 * Returns the sites filtered by the previously assigned conditions
124
	 *
125
	 * @param int $level Tree level constant, e.g. ONE, LIST or TREE
126
	 * @return \Aimeos\MShop\Locale\Item\Site\Iface Site tree
127
	 * @since 2021.04
128
	 */
129
	public function getTree( int $level = \Aimeos\Controller\Frontend\Site\Iface::TREE ) : \Aimeos\MShop\Locale\Item\Site\Iface
130
	{
131
		return $this->controller->getTree( $level );
132
	}
133
134
135
	/**
136
	 * Parses the given array and adds the conditions to the list of conditions
137
	 *
138
	 * @param array $conditions List of conditions, e.g. ['>' => ['site.status' => 0]]
139
	 * @return \Aimeos\Controller\Frontend\Site\Iface Site controller for fluent interface
140
	 * @since 2021.04
141
	 */
142
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Site\Iface
143
	{
144
		$this->controller->parse( $conditions );
145
		return $this;
146
	}
147
148
149
	/**
150
	 * Sets the site ID of node that is used as root node
151
	 *
152
	 * @param string|null $id Site ID
153
	 * @return \Aimeos\Controller\Frontend\Site\Iface Site controller for fluent interface
154
	 * @since 2021.04
155
	 */
156
	public function root( ?string $id = null ) : \Aimeos\Controller\Frontend\Site\Iface
157
	{
158
		$this->controller->root( $id );
159
		return $this;
160
	}
161
162
	/**
163
	 * Returns the sites filtered by the previously assigned conditions
164
	 *
165
	 * @param int &$total Parameter where the total number of found sites will be stored in
166
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Locale\Item\Site\Iface
167
	 * @since 2021.04
168
	 */
169
	 public function search( ?int &$total = null ) : \Aimeos\Map
170
	 {
171
		return $this->controller->search( $total );
172
	 }
173
174
175
	/**
176
	 * Sets the start value and the number of returned products for slicing the list of found products
177
	 *
178
	 * @param int $start Start value of the first product in the list
179
	 * @param int $limit Number of returned products
180
	 * @return \Aimeos\Controller\Frontend\Site\Iface Site controller for fluent interface
181
	 * @since 2021.04
182
	 */
183
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Site\Iface
184
	{
185
		$this->controller->slice( $start, $limit );
186
		return $this;
187
	}
188
189
190
	/**
191
	 * Sets the sorting of the result list
192
	 *
193
	 * @param string|null $key Search key for sorting of the result list and null for no sorting
194
	 * @return \Aimeos\Controller\Frontend\Site\Iface Site controller for fluent interface
195
	 * @since 2021.04
196
	 */
197
	public function sort( ?string $key = null ) : \Aimeos\Controller\Frontend\Site\Iface
198
	{
199
		$this->controller->sort( $key );
200
		return $this;
201
	}
202
203
204
	/**
205
	 * Injects the reference of the outmost object
206
	 *
207
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
208
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
209
	 */
210
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
211
	{
212
		parent::setObject( $object );
213
214
		$this->controller->setObject( $object );
0 ignored issues
show
Bug introduced by
The method setObject() does not exist on Aimeos\Controller\Frontend\Site\Iface. Since it exists in all sub-types, consider adding an abstract or default implementation to Aimeos\Controller\Frontend\Site\Iface. ( Ignorable by Annotation )

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

214
		$this->controller->/** @scrutinizer ignore-call */ 
215
                     setObject( $object );
Loading history...
215
216
		return $this;
217
	}
218
219
220
	/**
221
	 * Returns the frontend controller
222
	 *
223
	 * @return \Aimeos\Controller\Frontend\Iface Frontend controller object
224
	 */
225
	protected function getController() : \Aimeos\Controller\Frontend\Iface
226
	{
227
		return $this->controller;
228
	}
229
}
230