|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2025 |
|
6
|
|
|
* @package Controller |
|
7
|
|
|
* @subpackage Frontend |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Supplier\Decorator; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base for supplier 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\Supplier\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
use \Aimeos\Controller\Frontend\Common\Decorator\Traits; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
private \Aimeos\Controller\Frontend\Supplier\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 supplier manager, e.g. "supplier.status" |
|
72
|
|
|
* @param array|string $value Value or list of values to compare to |
|
73
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
74
|
|
|
* @since 2019.04 |
|
75
|
|
|
*/ |
|
76
|
|
|
public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
77
|
|
|
{ |
|
78
|
|
|
$this->controller->compare( $operator, $key, $value ); |
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Returns the supplier for the given supplier code |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $code Unique supplier code |
|
87
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items |
|
88
|
|
|
* @since 2019.04 |
|
89
|
|
|
*/ |
|
90
|
|
|
public function find( string $code ) : \Aimeos\MShop\Supplier\Item\Iface |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->controller->find( $code ); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Creates a search function string for the given name and parameters |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $name Name of the search function without parenthesis, e.g. "supplier:has" |
|
100
|
|
|
* @param array $params List of parameters for the search function with numeric keys starting at 0 |
|
101
|
|
|
* @return string Search function string that can be used in compare() |
|
102
|
|
|
*/ |
|
103
|
|
|
public function function( string $name, array $params ) : string |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->controller->function( $name, $params ); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Returns the supplier for the given supplier ID |
|
111
|
|
|
* |
|
112
|
|
|
* @param string $id Unique supplier ID |
|
113
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items |
|
114
|
|
|
* @since 2019.04 |
|
115
|
|
|
*/ |
|
116
|
|
|
public function get( string $id ) : \Aimeos\MShop\Supplier\Item\Iface |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->controller->get( $id ); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Adds a filter to return only items containing a reference to the given ID |
|
124
|
|
|
* |
|
125
|
|
|
* @param string $domain Domain name of the referenced item, e.g. "product" |
|
126
|
|
|
* @param string|null $type Type code of the reference, e.g. "default" or null for all types |
|
127
|
|
|
* @param string|null $refId ID of the referenced item of the given domain or null for all references |
|
128
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
129
|
|
|
* @since 2019.10 |
|
130
|
|
|
*/ |
|
131
|
|
|
public function has( string $domain, ?string $type = null, ?string $refId = null ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
132
|
|
|
{ |
|
133
|
|
|
$this->controller->has( $domain, $type, $refId ); |
|
134
|
|
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
|
140
|
|
|
* |
|
141
|
|
|
* @param array $conditions List of conditions, e.g. ['>' => ['supplier.dateback' => '2000-01-01 00:00:00']] |
|
142
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
143
|
|
|
* @since 2019.04 |
|
144
|
|
|
*/ |
|
145
|
|
|
public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
146
|
|
|
{ |
|
147
|
|
|
$this->controller->parse( $conditions ); |
|
148
|
|
|
return $this; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Returns the supplier item for the given supplier URL name |
|
154
|
|
|
* |
|
155
|
|
|
* @param string $name supplier URL name |
|
156
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items |
|
157
|
|
|
* @since 2023.10 |
|
158
|
|
|
*/ |
|
159
|
|
|
public function resolve( string $name ) : \Aimeos\MShop\Supplier\Item\Iface |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->controller->resolve( $name ); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Returns the suppliers filtered by the previously assigned conditions |
|
167
|
|
|
* |
|
168
|
|
|
* @param int &$total Parameter where the total number of found suppliers will be stored in |
|
169
|
|
|
* @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Supplier\Item\Iface |
|
170
|
|
|
* @since 2019.04 |
|
171
|
|
|
*/ |
|
172
|
|
|
public function search( ?int &$total = null ) : \Aimeos\Map |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->controller->search( $total ); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* Sets the start value and the number of returned supplier items for slicing the list of found supplier items |
|
180
|
|
|
* |
|
181
|
|
|
* @param int $start Start value of the first supplier item in the list |
|
182
|
|
|
* @param int $limit Number of returned supplier items |
|
183
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
184
|
|
|
* @since 2019.04 |
|
185
|
|
|
*/ |
|
186
|
|
|
public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
187
|
|
|
{ |
|
188
|
|
|
$this->controller->slice( $start, $limit ); |
|
189
|
|
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Sets the sorting of the result list |
|
195
|
|
|
* |
|
196
|
|
|
* @param string|null $key Sorting key of the result list like "supplier.label", null for no sorting |
|
197
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
198
|
|
|
* @since 2019.04 |
|
199
|
|
|
*/ |
|
200
|
|
|
public function sort( ?string $key = null ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
201
|
|
|
{ |
|
202
|
|
|
$this->controller->sort( $key ); |
|
203
|
|
|
return $this; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Sets the referenced domains that will be fetched too when retrieving items |
|
209
|
|
|
* |
|
210
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
|
211
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
|
212
|
|
|
* @since 2019.04 |
|
213
|
|
|
*/ |
|
214
|
|
|
public function uses( array $domains ) : \Aimeos\Controller\Frontend\Supplier\Iface |
|
215
|
|
|
{ |
|
216
|
|
|
$this->controller->uses( $domains ); |
|
217
|
|
|
return $this; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Injects the reference of the outmost object |
|
223
|
|
|
* |
|
224
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator |
|
225
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls |
|
226
|
|
|
*/ |
|
227
|
|
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface |
|
228
|
|
|
{ |
|
229
|
|
|
parent::setObject( $object ); |
|
230
|
|
|
|
|
231
|
|
|
$this->controller->setObject( $object ); |
|
|
|
|
|
|
232
|
|
|
|
|
233
|
|
|
return $this; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Returns the frontend controller |
|
239
|
|
|
* |
|
240
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Frontend controller object |
|
241
|
|
|
*/ |
|
242
|
|
|
protected function getController() : \Aimeos\Controller\Frontend\Iface |
|
243
|
|
|
{ |
|
244
|
|
|
return $this->controller; |
|
245
|
|
|
} |
|
246
|
|
|
} |
|
247
|
|
|
|