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\Subscription\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for subscription 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\Subscription\Iface |
23
|
|
|
{ |
24
|
|
|
use \Aimeos\Controller\Frontend\Common\Decorator\Traits; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
private \Aimeos\Controller\Frontend\Subscription\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
|
|
|
* Cancels an active subscription |
69
|
|
|
* |
70
|
|
|
* @param string $id Unique subscription ID |
71
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Canceled subscription item |
72
|
|
|
*/ |
73
|
|
|
public function cancel( string $id ) : \Aimeos\MShop\Subscription\Item\Iface |
74
|
|
|
{ |
75
|
|
|
return $this->controller->cancel( $id ); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Adds generic condition for filtering |
81
|
|
|
* |
82
|
|
|
* @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" |
83
|
|
|
* @param string $key Search key defined by the subscription manager, e.g. "subscription.status" |
84
|
|
|
* @param array|string $value Value or list of values to compare to |
85
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Subscription controller for fluent interface |
86
|
|
|
* @since 2019.04 |
87
|
|
|
*/ |
88
|
|
|
public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Subscription\Iface |
89
|
|
|
{ |
90
|
|
|
$this->controller->compare( $operator, $key, $value ); |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Returns the subscription for the given subscription ID |
97
|
|
|
* |
98
|
|
|
* @param string $id Unique subscription ID |
99
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Subscription item including the referenced domains items |
100
|
|
|
* @since 2019.04 |
101
|
|
|
*/ |
102
|
|
|
public function get( string $id ) : \Aimeos\MShop\Subscription\Item\Iface |
103
|
|
|
{ |
104
|
|
|
return $this->controller->get( $id ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Returns the available interval attribute items |
110
|
|
|
* |
111
|
|
|
* @return \Aimeos\Map Associative list of intervals as keys and items implementing \Aimeos\MShop\Attribute\Item\Iface |
112
|
|
|
*/ |
113
|
|
|
public function getIntervals() : \Aimeos\Map |
114
|
|
|
{ |
115
|
|
|
return $this->controller->getIntervals(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
121
|
|
|
* |
122
|
|
|
* @param array $conditions List of conditions, e.g. ['>' => ['subscription.interval' => 'P0Y1M0W0D']] |
123
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Subscription controller for fluent interface |
124
|
|
|
* @since 2019.04 |
125
|
|
|
*/ |
126
|
|
|
public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Subscription\Iface |
127
|
|
|
{ |
128
|
|
|
$this->controller->parse( $conditions ); |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Saves the modified subscription item |
135
|
|
|
* |
136
|
|
|
* @param \Aimeos\MShop\Subscription\Item\Iface $item Subscription object |
137
|
|
|
* @return \Aimeos\MShop\Subscription\Item\Iface Saved subscription item |
138
|
|
|
*/ |
139
|
|
|
public function save( \Aimeos\MShop\Subscription\Item\Iface $item ) : \Aimeos\MShop\Subscription\Item\Iface |
140
|
|
|
{ |
141
|
|
|
return $this->controller->save( $item ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Returns the subscriptions filtered by the previously assigned conditions |
147
|
|
|
* |
148
|
|
|
* @param int &$total Parameter where the total number of found subscriptions will be stored in |
149
|
|
|
* @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Subscription\Item\Iface |
150
|
|
|
* @since 2019.04 |
151
|
|
|
*/ |
152
|
|
|
public function search( ?int &$total = null ) : \Aimeos\Map |
153
|
|
|
{ |
154
|
|
|
return $this->controller->search( $total ); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Sets the start value and the number of returned subscription items for slicing the list of found subscription items |
160
|
|
|
* |
161
|
|
|
* @param int $start Start value of the first subscription item in the list |
162
|
|
|
* @param int $limit Number of returned subscription items |
163
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Subscription controller for fluent interface |
164
|
|
|
* @since 2019.04 |
165
|
|
|
*/ |
166
|
|
|
public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Subscription\Iface |
167
|
|
|
{ |
168
|
|
|
$this->controller->slice( $start, $limit ); |
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Sets the sorting of the result list |
175
|
|
|
* |
176
|
|
|
* @param string|null $key Sorting key of the result list like "interval", null for no sorting |
177
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Subscription controller for fluent interface |
178
|
|
|
* @since 2019.04 |
179
|
|
|
*/ |
180
|
|
|
public function sort( ?string $key = null ) : \Aimeos\Controller\Frontend\Subscription\Iface |
181
|
|
|
{ |
182
|
|
|
$this->controller->sort( $key ); |
183
|
|
|
return $this; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Injects the reference of the outmost object |
189
|
|
|
* |
190
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator |
191
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls |
192
|
|
|
*/ |
193
|
|
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface |
194
|
|
|
{ |
195
|
|
|
parent::setObject( $object ); |
196
|
|
|
|
197
|
|
|
$this->controller->setObject( $object ); |
|
|
|
|
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Sets the referenced domains that will be fetched too when retrieving items |
205
|
|
|
* |
206
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
207
|
|
|
* @return \Aimeos\Controller\Frontend\Subscription\Iface Subscription controller for fluent interface |
208
|
|
|
* @since 2022.04 |
209
|
|
|
*/ |
210
|
|
|
public function uses( array $domains ) : \Aimeos\Controller\Frontend\Subscription\Iface |
211
|
|
|
{ |
212
|
|
|
$this->controller->uses( $domains ); |
213
|
|
|
return $this; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Returns the frontend controller |
219
|
|
|
* |
220
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Frontend controller object |
221
|
|
|
*/ |
222
|
|
|
protected function getController() : \Aimeos\Controller\Frontend\Iface |
223
|
|
|
{ |
224
|
|
|
return $this->controller; |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|