1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018 |
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
|
|
|
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\Supplier\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( $name, array $param ) |
51
|
|
|
{ |
52
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Clones objects in controller and resets values |
58
|
|
|
*/ |
59
|
|
|
public function __clone() |
60
|
|
|
{ |
61
|
|
|
$this->controller = clone $this->controller; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Adds generic condition for filtering |
67
|
|
|
* |
68
|
|
|
* @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" |
69
|
|
|
* @param string $key Search key defined by the supplier manager, e.g. "supplier.status" |
70
|
|
|
* @param array|string $value Value or list of values to compare to |
71
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
72
|
|
|
* @since 2019.04 |
73
|
|
|
*/ |
74
|
|
|
public function compare( $operator, $key, $value ) |
75
|
|
|
{ |
76
|
|
|
$this->controller->compare( $operator, $key, $value ); |
77
|
|
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns the supplier for the given supplier code |
83
|
|
|
* |
84
|
|
|
* @param string $code Unique supplier code |
85
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items |
86
|
|
|
* @since 2019.04 |
87
|
|
|
*/ |
88
|
|
|
public function find( $code ) |
89
|
|
|
{ |
90
|
|
|
return $this->controller->find( $code ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Returns the supplier for the given supplier ID |
96
|
|
|
* |
97
|
|
|
* @param string $id Unique supplier ID |
98
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item including the referenced domains items |
99
|
|
|
* @since 2019.04 |
100
|
|
|
*/ |
101
|
|
|
public function get( $id ) |
102
|
|
|
{ |
103
|
|
|
return $this->controller->get( $id ); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
109
|
|
|
* |
110
|
|
|
* @param array $conditions List of conditions, e.g. ['>' => ['supplier.dateback' => '2000-01-01 00:00:00']] |
111
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
112
|
|
|
* @since 2019.04 |
113
|
|
|
*/ |
114
|
|
|
public function parse( array $conditions ) |
115
|
|
|
{ |
116
|
|
|
$this->controller->parse( $conditions ); |
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Returns the suppliers filtered by the previously assigned conditions |
123
|
|
|
* |
124
|
|
|
* @param integer &$total Parameter where the total number of found suppliers will be stored in |
125
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface[] Ordered list of supplier items |
126
|
|
|
* @since 2019.04 |
127
|
|
|
*/ |
128
|
|
|
public function search( &$total = null ) |
129
|
|
|
{ |
130
|
|
|
return $this->controller->search( $total ); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Sets the start value and the number of returned supplier items for slicing the list of found supplier items |
136
|
|
|
* |
137
|
|
|
* @param integer $start Start value of the first supplier item in the list |
138
|
|
|
* @param integer $limit Number of returned supplier items |
139
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
140
|
|
|
* @since 2019.04 |
141
|
|
|
*/ |
142
|
|
|
public function slice( $start, $limit ) |
143
|
|
|
{ |
144
|
|
|
$this->controller->slice( $start, $limit ); |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Sets the sorting of the result list |
151
|
|
|
* |
152
|
|
|
* @param string|null $key Sorting key of the result list like "supplier.label", null for no sorting |
153
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
154
|
|
|
* @since 2019.04 |
155
|
|
|
*/ |
156
|
|
|
public function sort( $key = null ) |
157
|
|
|
{ |
158
|
|
|
$this->controller->sort( $key ); |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Sets the referenced domains that will be fetched too when retrieving items |
165
|
|
|
* |
166
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
167
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Supplier controller for fluent interface |
168
|
|
|
* @since 2019.04 |
169
|
|
|
*/ |
170
|
|
|
public function uses( array $domains ) |
171
|
|
|
{ |
172
|
|
|
$this->controller->uses( $domains ); |
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Injects the reference of the outmost object |
179
|
|
|
* |
180
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator |
181
|
|
|
* @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls |
182
|
|
|
*/ |
183
|
|
|
public function setObject( \Aimeos\Controller\Frontend\Iface $object ) |
184
|
|
|
{ |
185
|
|
|
parent::setObject( $object ); |
186
|
|
|
|
187
|
|
|
$this->controller->setObject( $object ); |
188
|
|
|
|
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Returns the frontend controller |
195
|
|
|
* |
196
|
|
|
* @return \Aimeos\Controller\Frontend\Supplier\Iface Frontend controller object |
197
|
|
|
*/ |
198
|
|
|
protected function getController() |
199
|
|
|
{ |
200
|
|
|
return $this->controller; |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|