Base::find()   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\Customer\Decorator;
12
13
14
/**
15
 * Base for customer 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\Customer\Iface
23
{
24
	use \Aimeos\Controller\Frontend\Common\Decorator\Traits;
25
26
27
	private \Aimeos\Controller\Frontend\Customer\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
	 * Adds and returns a new customer item object
60
	 *
61
	 * @param array $values Values added to the customer item (new or existing) like "customer.code"
62
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
63
	 * @since 2019.04
64
	 */
65
	public function add( array $values ) : \Aimeos\Controller\Frontend\Customer\Iface
66
	{
67
		$this->controller->add( $values );
68
		return $this;
69
	}
70
71
72
	/**
73
	 * Adds the given address item to the customer object (not yet stored)
74
	 *
75
	 * @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item to add
76
	 * @param int|null $pos Position (key) in the list of address items or null to add the item at the end
77
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
78
	 * @since 2019.04
79
	 */
80
	public function addAddressItem( \Aimeos\MShop\Common\Item\Address\Iface $item,
81
		?int $position = null ) : \Aimeos\Controller\Frontend\Customer\Iface
82
	{
83
		$this->controller->addAddressItem( $item, $position );
84
		return $this;
85
	}
86
87
88
	/**
89
	 * Adds the given list item to the customer object (not yet stored)
90
	 *
91
	 * @param string $domain Domain name the referenced item belongs to
92
	 * @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item to add
93
	 * @param \Aimeos\MShop\Common\Item\Iface|null $refItem Referenced item to add or null if list item contains refid value
94
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
95
	 * @since 2019.04
96
	 */
97
	public function addListItem( string $domain, \Aimeos\MShop\Common\Item\Lists\Iface $item,
98
		?\Aimeos\MShop\Common\Item\Iface $refItem = null ) : \Aimeos\Controller\Frontend\Customer\Iface
99
	{
100
		$this->controller->addListItem( $domain, $item, $refItem );
101
		return $this;
102
	}
103
104
105
	/**
106
	 * Adds the given property item to the customer object (not yet stored)
107
	 *
108
	 * @param \Aimeos\MShop\Common\Item\Property\Iface $item Property item to add
109
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
110
	 * @since 2019.04
111
	 */
112
	public function addPropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item ) : \Aimeos\Controller\Frontend\Customer\Iface
113
	{
114
		$this->controller->addPropertyItem( $item );
115
		return $this;
116
	}
117
118
119
	/**
120
	 * Creates a new address item object pre-filled with the given values
121
	 *
122
	 * @param array $values Associative list of key/value pairs for populating the item
123
	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Address item
124
	 * @since 2019.04
125
	 */
126
	public function createAddressItem( array $values = [] ) : \Aimeos\MShop\Customer\Item\Address\Iface
127
	{
128
		return $this->controller->createAddressItem( $values );
129
	}
130
131
132
	/**
133
	 * Creates a new list item object pre-filled with the given values
134
	 *
135
	 * @param array $values Associative list of key/value pairs for populating the item
136
	 * @return \Aimeos\MShop\Common\Item\Lists\Iface List item
137
	 * @since 2019.04
138
	 */
139
	public function createListItem( array $values = [] ) : \Aimeos\MShop\Common\Item\Lists\Iface
140
	{
141
		return $this->controller->createListItem( $values );
142
	}
143
144
145
	/**
146
	 * Creates a new property item object pre-filled with the given values
147
	 *
148
	 * @param array $values Associative list of key/value pairs for populating the item
149
	 * @return \Aimeos\MShop\Common\Item\Property\Iface Property item
150
	 * @since 2019.04
151
	 */
152
	public function createPropertyItem( array $values = [] ) : \Aimeos\MShop\Common\Item\Property\Iface
153
	{
154
		return $this->controller->createPropertyItem( $values );
155
	}
156
157
158
159
	/**
160
	 * Deletes a customer item that belongs to the current authenticated user
161
	 *
162
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
163
	 * @since 2017.04
164
	 */
165
	public function delete() : \Aimeos\Controller\Frontend\Customer\Iface
166
	{
167
		$this->controller->delete();
168
		return $this;
169
	}
170
171
172
	/**
173
	 * Removes the given address item from the customer object (not yet stored)
174
	 *
175
	 * @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item to remove
176
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
177
	 */
178
	public function deleteAddressItem( \Aimeos\MShop\Common\Item\Address\Iface $item ) : \Aimeos\Controller\Frontend\Customer\Iface
179
	{
180
		$this->controller->deleteAddressItem( $item );
181
		return $this;
182
	}
183
184
185
	/**
186
	 * Removes the given list item from the customer object (not yet stored)
187
	 *
188
	 * @param string $domain Domain name the referenced item belongs to
189
	 * @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item to remove
190
	 * @param \Aimeos\MShop\Common\Item\Iface|null $refItem Referenced item to remove or null if only list item should be removed
191
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
192
	 */
193
	public function deleteListItem( string $domain, \Aimeos\MShop\Common\Item\Lists\Iface $listItem,
194
		?\Aimeos\MShop\Common\Item\Iface $refItem = null ) : \Aimeos\Controller\Frontend\Customer\Iface
195
	{
196
		$this->controller->deleteListItem( $domain, $listItem, $refItem );
197
		return $this;
198
	}
199
200
201
	/**
202
	 * Removes the given property item from the customer object (not yet stored)
203
	 *
204
	 * @param \Aimeos\MShop\Common\Item\Property\Iface $item Property item to remove
205
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
206
	 */
207
	public function deletePropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item ) : \Aimeos\Controller\Frontend\Customer\Iface
208
	{
209
		$this->controller->deletePropertyItem( $item );
210
		return $this;
211
	}
212
213
214
	/**
215
	 * Returns the customer item for the given code
216
	 *
217
	 * This method doesn't check if the customer item belongs to the logged in user!
218
	 *
219
	 * @param string $code Unique customer code
220
	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item
221
	 * @since 2019.04
222
	 */
223
	public function find( string $code ) : \Aimeos\MShop\Customer\Item\Iface
224
	{
225
		return $this->controller->find( $code );
226
	}
227
228
229
	/**
230
	 * Returns the customer item for the current authenticated user
231
	 *
232
	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item
233
	 * @since 2019.04
234
	 */
235
	public function get() : \Aimeos\MShop\Customer\Item\Iface
236
	{
237
		return $this->controller->get();
238
	}
239
240
241
	/**
242
	 * Adds or updates the modified customer item in the storage
243
	 *
244
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
245
	 * @since 2019.04
246
	 */
247
	public function store() : \Aimeos\Controller\Frontend\Customer\Iface
248
	{
249
		$this->controller->store();
250
		return $this;
251
	}
252
253
254
	/**
255
	 * Sets the domains that will be used when working with the customer item
256
	 *
257
	 * @param array $domains Domain names of the referenced items that should be fetched too
258
	 * @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface
259
	 * @since 2019.04
260
	 */
261
	public function uses( array $domains ) : \Aimeos\Controller\Frontend\Customer\Iface
262
	{
263
		$this->controller->uses( $domains );
264
		return $this;
265
	}
266
267
268
	/**
269
	 * Injects the reference of the outmost object
270
	 *
271
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
272
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
273
	 */
274
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
275
	{
276
		parent::setObject( $object );
277
278
		$this->controller->setObject( $object );
0 ignored issues
show
Bug introduced by
The method setObject() does not exist on Aimeos\Controller\Frontend\Customer\Iface. Since it exists in all sub-types, consider adding an abstract or default implementation to Aimeos\Controller\Frontend\Customer\Iface. ( Ignorable by Annotation )

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

278
		$this->controller->/** @scrutinizer ignore-call */ 
279
                     setObject( $object );
Loading history...
279
280
		return $this;
281
	}
282
283
284
	/**
285
	 * Returns the frontend controller
286
	 *
287
	 * @return \Aimeos\Controller\Frontend\Iface Frontend controller object
288
	 * @since 2017.04
289
	 */
290
	protected function getController() : \Aimeos\Controller\Frontend\Iface
291
	{
292
		return $this->controller;
293
	}
294
}
295