Passed
Push — master ( 40eed1...d6e4b0 )
by Aimeos
07:29 queued 04:51
created

Base   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 189
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 27
dl 0
loc 189
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A compare() 0 4 1
A slice() 0 4 1
A save() 0 3 1
A __call() 0 3 1
A sort() 0 4 1
A __construct() 0 5 1
A search() 0 3 1
A get() 0 3 1
A parse() 0 4 1
A setObject() 0 7 1
A getController() 0 3 1
A update() 0 4 1
A uses() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2023
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
	use \Aimeos\Controller\Frontend\Common\Decorator\Traits;
25
26
27
	private \Aimeos\Controller\Frontend\Order\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 generic condition for filtering orders
60
	 *
61
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
62
	 * @param string $key Search key defined by the order manager, e.g. "order.status"
63
	 * @param array|string $value Value or list of values to compare to
64
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
65
	 * @since 2019.04
66
	 */
67
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Order\Iface
68
	{
69
		$this->controller->compare( $operator, $key, $value );
70
		return $this;
71
	}
72
73
74
	/**
75
	 * Returns the order for the given order ID
76
	 *
77
	 * @param string $id Unique order ID
78
	 * @param bool $default Use default criteria to limit orders
79
	 * @return \Aimeos\MShop\Order\Item\Iface Order item object
80
	 * @since 2019.04
81
	 */
82
	public function get( string $id, bool $default = true ) : \Aimeos\MShop\Order\Item\Iface
83
	{
84
		return $this->controller->get( $id, $default );
85
	}
86
87
88
	/**
89
	 * Parses the given array and adds the conditions to the list of conditions
90
	 *
91
	 * @param array $conditions List of conditions, e.g. ['&&' => [['>' => ['order.statuspayment' => 0]], ['==' => ['order.type' => 'web']]]]
92
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
93
	 * @since 2019.04
94
	 */
95
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Order\Iface
96
	{
97
		$this->controller->parse( $conditions );
98
		return $this;
99
	}
100
101
102
	/**
103
	 * Updates the given order item in the storage
104
	 *
105
	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
106
	 * @return \Aimeos\MShop\Order\Item\Iface $orderItem Saved order item object
107
	 * @since 2019.04
108
	 */
109
	public function save( \Aimeos\MShop\Order\Item\Iface $orderItem ) : \Aimeos\MShop\Order\Item\Iface
110
	{
111
		return $this->controller->save( $orderItem );
112
	}
113
114
115
	/**
116
	 * Returns the orders filtered by the previously assigned conditions
117
	 *
118
	 * @param int &$total Parameter where the total number of found attributes will be stored in
119
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Order\Item\Iface
120
	 * @since 2019.04
121
	 */
122
	public function search( int &$total = null ) : \Aimeos\Map
123
	{
124
		return $this->controller->search( $total );
125
	}
126
127
128
	/**
129
	 * Sets the start value and the number of returned orders for slicing the list of found orders
130
	 *
131
	 * @param int $start Start value of the first order in the list
132
	 * @param int $limit Number of returned orders
133
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
134
	 * @since 2019.04
135
	 */
136
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Order\Iface
137
	{
138
		$this->controller->slice( $start, $limit );
139
		return $this;
140
	}
141
142
143
	/**
144
	 * Sets the sorting of the result list
145
	 *
146
	 * @param string|null $key Sorting of the result list like "-order.id", null for no sorting
147
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
148
	 * @since 2019.04
149
	 */
150
	public function sort( string $key = null ) : \Aimeos\Controller\Frontend\Order\Iface
151
	{
152
		$this->controller->sort( $key );
153
		return $this;
154
	}
155
156
157
	/**
158
	 * Updates stock levels and coupons counts
159
	 *
160
	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
161
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
162
	 * @since 2024.01
163
	 */
164
	public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) : \Aimeos\Controller\Frontend\Order\Iface
165
	{
166
		$this->controller->update( $orderItem );
167
		return $this;
168
	}
169
170
171
	/**
172
	 * Sets the referenced domains that will be fetched too when retrieving items
173
	 *
174
	 * @param array $domains Domain names of the referenced items that should be fetched too
175
	 * @return \Aimeos\Controller\Frontend\Order\Iface Order controller for fluent interface
176
	 * @since 2020.04
177
	 */
178
	public function uses( array $domains ) : \Aimeos\Controller\Frontend\Order\Iface
179
	{
180
		$this->controller->uses( $domains );
181
		return $this;
182
	}
183
184
185
	/**
186
	 * Injects the reference of the outmost object
187
	 *
188
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
189
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
190
	 */
191
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
192
	{
193
		parent::setObject( $object );
194
195
		$this->controller->setObject( $object );
0 ignored issues
show
Bug introduced by
The method setObject() does not exist on Aimeos\Controller\Frontend\Order\Iface. Since it exists in all sub-types, consider adding an abstract or default implementation to Aimeos\Controller\Frontend\Order\Iface. ( Ignorable by Annotation )

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

195
		$this->controller->/** @scrutinizer ignore-call */ 
196
                     setObject( $object );
Loading history...
196
197
		return $this;
198
	}
199
200
201
	/**
202
	 * Returns the frontend controller
203
	 *
204
	 * @return \Aimeos\Controller\Frontend\Iface Frontend controller object
205
	 */
206
	protected function getController() : \Aimeos\Controller\Frontend\Iface
207
	{
208
		return $this->controller;
209
	}
210
}
211