Passed
Push — master ( d4b18c...ae3ece )
by Aimeos
01:45
created

Base   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 186
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 13
eloc 26
dl 0
loc 186
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 1
A __construct() 0 6 1
A compare() 0 4 1
A slice() 0 4 1
A store() 0 3 1
A save() 0 3 1
A add() 0 4 1
A sort() 0 4 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
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2018
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( $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( $baseId, array $values = [] )
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( $operator, $key, $value )
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 boolean $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( $id, $default = true )
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 )
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 )
123
	{
124
		return $this->controller->save( $orderItem );
125
	}
126
127
128
	/**
129
	 * Returns the orders filtered by the previously assigned conditions
130
	 *
131
	 * @param string[] $domains Domain names of items that are associated with the orders and that should be fetched too
132
	 * @return \Aimeos\MShop\Order\Item\Iface[] Ordered list of order items
133
	 * @since 2019.04
134
	 */
135
	public function search( &$total = null )
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 integer $start Start value of the first order in the list
145
	 * @param integer $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( $start, $limit )
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( $key = null )
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()
177
	{
178
		return $this->controller->store();
179
	}
180
181
182
	/**
183
	 * Injects the reference of the outmost object
184
	 *
185
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
186
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
187
	 */
188
	public function setObject( \Aimeos\Controller\Frontend\Iface $object )
189
	{
190
		parent::setObject( $object );
191
192
		$this->controller->setObject( $object );
193
194
		return $this;
195
	}
196
197
198
	/**
199
	 * Returns the frontend controller
200
	 *
201
	 * @return \Aimeos\Controller\Frontend\Order\Iface Frontend controller object
202
	 */
203
	protected function getController()
204
	{
205
		return $this->controller;
206
	}
207
}
208