1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2016-2020 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Order\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for order 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\Order\Iface |
23
|
|
|
{ |
24
|
|
|
private $controller; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initializes the controller decorator. |
29
|
|
|
* |
30
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32
|
|
|
*/ |
33
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
34
|
|
|
{ |
35
|
|
|
parent::__construct( $context ); |
36
|
|
|
|
37
|
|
|
$iface = \Aimeos\Controller\Frontend\Order\Iface::class; |
38
|
|
|
$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Passes unknown methods to wrapped objects. |
44
|
|
|
* |
45
|
|
|
* @param string $name Name of the method |
46
|
|
|
* @param array $param List of method parameter |
47
|
|
|
* @return mixed Returns the value of the called method |
48
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
49
|
|
|
*/ |
50
|
|
|
public function __call( string $name, array $param ) |
51
|
|
|
{ |
52
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Adds the values to the order object (not yet stored) |
58
|
|
|
* |
59
|
|
|
* @param string $baseId ID of the stored basket |
60
|
|
|
* @param array $values Values added to the order item (new or existing) like "order.type" |
61
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
62
|
|
|
* @since 2019.04 |
63
|
|
|
*/ |
64
|
|
|
public function add( string $baseId, array $values = [] ) : \Aimeos\Controller\Frontend\Order\Iface |
65
|
|
|
{ |
66
|
|
|
$this->controller->add( $baseId, $values ); |
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Adds generic condition for filtering orders |
73
|
|
|
* |
74
|
|
|
* @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" |
75
|
|
|
* @param string $key Search key defined by the order manager, e.g. "order.status" |
76
|
|
|
* @param array|string $value Value or list of values to compare to |
77
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
78
|
|
|
* @since 2019.04 |
79
|
|
|
*/ |
80
|
|
|
public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Order\Iface |
81
|
|
|
{ |
82
|
|
|
$this->controller->compare( $operator, $key, $value ); |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns the order for the given order ID |
89
|
|
|
* |
90
|
|
|
* @param string $id Unique order ID |
91
|
|
|
* @param bool $default Use default criteria to limit orders |
92
|
|
|
* @return \Aimeos\MShop\Order\Item\Iface Order item object |
93
|
|
|
* @since 2019.04 |
94
|
|
|
*/ |
95
|
|
|
public function get( string $id, bool $default = true ) : \Aimeos\MShop\Order\Item\Iface |
96
|
|
|
{ |
97
|
|
|
return $this->controller->get( $id, $default ); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
103
|
|
|
* |
104
|
|
|
* @param array $conditions List of conditions, e.g. ['&&' => [['>' => ['order.statuspayment' => 0]], ['==' => ['order.type' => 'web']]]] |
105
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
106
|
|
|
* @since 2019.04 |
107
|
|
|
*/ |
108
|
|
|
public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Order\Iface |
109
|
|
|
{ |
110
|
|
|
$this->controller->parse( $conditions ); |
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Updates the given order item in the storage |
117
|
|
|
* |
118
|
|
|
* @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
119
|
|
|
* @return \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item object |
120
|
|
|
* @since 2019.04 |
121
|
|
|
*/ |
122
|
|
|
public function save( \Aimeos\MShop\Order\Item\Iface $orderItem ) : \Aimeos\MShop\Order\Item\Iface |
123
|
|
|
{ |
124
|
|
|
return $this->controller->save( $orderItem ); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Returns the orders filtered by the previously assigned conditions |
130
|
|
|
* |
131
|
|
|
* @param int &$total Parameter where the total number of found attributes will be stored in |
132
|
|
|
* @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Order\Item\Iface |
133
|
|
|
* @since 2019.04 |
134
|
|
|
*/ |
135
|
|
|
public function search( int &$total = null ) : \Aimeos\Map |
136
|
|
|
{ |
137
|
|
|
return $this->controller->search( $total ); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Sets the start value and the number of returned orders for slicing the list of found orders |
143
|
|
|
* |
144
|
|
|
* @param int $start Start value of the first order in the list |
145
|
|
|
* @param int $limit Number of returned orders |
146
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
147
|
|
|
* @since 2019.04 |
148
|
|
|
*/ |
149
|
|
|
public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Order\Iface |
150
|
|
|
{ |
151
|
|
|
$this->controller->slice( $start, $limit ); |
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Sets the sorting of the result list |
158
|
|
|
* |
159
|
|
|
* @param string|null $key Sorting of the result list like "-order.id", null for no sorting |
160
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
161
|
|
|
* @since 2019.04 |
162
|
|
|
*/ |
163
|
|
|
public function sort( string $key = null ) : \Aimeos\Controller\Frontend\Order\Iface |
164
|
|
|
{ |
165
|
|
|
$this->controller->sort( $key ); |
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Saves the modified order item in the storage and blocks the stock and coupon codes |
172
|
|
|
* |
173
|
|
|
* @return \Aimeos\MShop\Order\Item\Iface New or updated order item object |
174
|
|
|
* @since 2019.04 |
175
|
|
|
*/ |
176
|
|
|
public function store() : \Aimeos\MShop\Order\Item\Iface |
177
|
|
|
{ |
178
|
|
|
return $this->controller->store(); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Sets the referenced domains that will be fetched too when retrieving items |
184
|
|
|
* |
185
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
186
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface |
187
|
|
|
* @since 2020.04 |
188
|
|
|
*/ |
189
|
|
|
public function uses( array $domains ) : \Aimeos\Controller\Frontend\Order\Iface |
190
|
|
|
{ |
191
|
|
|
$this->controller->uses( $domains ); |
192
|
|
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Injects the reference of the outmost object |
198
|
|
|
* |
199
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator |
200
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls |
201
|
|
|
*/ |
202
|
|
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface |
203
|
|
|
{ |
204
|
|
|
parent::setObject( $object ); |
205
|
|
|
|
206
|
|
|
$this->controller->setObject( $object ); |
207
|
|
|
|
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Returns the frontend controller |
214
|
|
|
* |
215
|
|
|
* @return \Aimeos\Controller\Frontend\Order\Iface Frontend controller object |
216
|
|
|
*/ |
217
|
|
|
protected function getController() : \Aimeos\Controller\Frontend\Order\Iface |
218
|
|
|
{ |
219
|
|
|
return $this->controller; |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|