|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
4
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2024 |
|
5
|
|
|
* @package MShop |
|
6
|
|
|
* @subpackage Order |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
namespace Aimeos\MShop\Order\Item\Status; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Default implementation of the order status object. |
|
15
|
|
|
* |
|
16
|
|
|
* @package MShop |
|
17
|
|
|
* @subpackage Order |
|
18
|
|
|
*/ |
|
19
|
|
|
class Standard |
|
20
|
|
|
extends \Aimeos\MShop\Order\Item\Status\Base |
|
21
|
|
|
implements \Aimeos\MShop\Order\Item\Status\Iface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Returns the parentid of the order status. |
|
25
|
|
|
* |
|
26
|
|
|
* @return string|null Parent ID of the order |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getParentId() : ?string |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->get( 'order.status.parentid' ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Sets the parentid of the order status. |
|
36
|
|
|
* |
|
37
|
|
|
* @param string|null $parentid Parent ID of the order status |
|
38
|
|
|
* @return \Aimeos\MShop\Order\Item\Status\Iface Order status item for chaining method calls |
|
39
|
|
|
*/ |
|
40
|
|
|
public function setParentId( ?string $parentid ) : \Aimeos\MShop\Common\Item\Iface |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->set( 'order.status.parentid', $parentid ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Returns the type of the order status. |
|
48
|
|
|
* |
|
49
|
|
|
* @return string Type of the order status |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getType() : string |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->get( 'order.status.type', '' ); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Sets the type of the order status. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $type Type of the order status |
|
61
|
|
|
* @return \Aimeos\MShop\Order\Item\Status\Iface Order status item for chaining method calls |
|
62
|
|
|
*/ |
|
63
|
|
|
public function setType( string $type ) : \Aimeos\MShop\Common\Item\Iface |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->set( 'order.status.type', $this->checkCode( $type ) ); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Returns the value of the order status. |
|
71
|
|
|
* |
|
72
|
|
|
* @return string Value of the order status |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getValue() : string |
|
75
|
|
|
{ |
|
76
|
|
|
return (string) $this->get( 'order.status.value', '' ); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Sets the value of the order status. |
|
82
|
|
|
* |
|
83
|
|
|
* @param string $value Value of the order status |
|
84
|
|
|
* @return \Aimeos\MShop\Order\Item\Status\Iface Order status item for chaining method calls |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setValue( string $value ) : \Aimeos\MShop\Order\Item\Status\Iface |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->set( 'order.status.value', $value ); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
/* |
|
93
|
|
|
* Sets the item values from the given array and removes that entries from the list |
|
94
|
|
|
* |
|
95
|
|
|
* @param array &$list Associative list of item keys and their values |
|
96
|
|
|
* @param bool True to set private properties too, false for public only |
|
97
|
|
|
* @return \Aimeos\MShop\Order\Item\Status\Iface Order status item for chaining method calls |
|
98
|
|
|
*/ |
|
99
|
|
|
public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface |
|
100
|
|
|
{ |
|
101
|
|
|
$item = parent::fromArray( $list, $private ); |
|
102
|
|
|
|
|
103
|
|
|
foreach( $list as $key => $value ) |
|
104
|
|
|
{ |
|
105
|
|
|
switch( $key ) |
|
106
|
|
|
{ |
|
107
|
|
|
case 'order.status.parentid': !$private ?: $item = $item->setParentId( $value ); break; |
|
|
|
|
|
|
108
|
|
|
case 'order.status.type': $item = $item->setType( $value ); break; |
|
|
|
|
|
|
109
|
|
|
case 'order.status.value': $item = $item->setValue( $value ); break; |
|
|
|
|
|
|
110
|
|
|
default: continue 2; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
unset( $list[$key] ); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
return $item; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Returns the item values as array. |
|
123
|
|
|
* |
|
124
|
|
|
* @param bool True to return private properties, false for public only |
|
125
|
|
|
* @return array Associative list of item properties and their values |
|
126
|
|
|
*/ |
|
127
|
|
|
public function toArray( bool $private = false ) : array |
|
128
|
|
|
{ |
|
129
|
|
|
$list = parent::toArray( $private ); |
|
130
|
|
|
|
|
131
|
|
|
$list['order.status.type'] = $this->getType(); |
|
132
|
|
|
$list['order.status.value'] = $this->getValue(); |
|
133
|
|
|
|
|
134
|
|
|
if( $private === true ) { |
|
135
|
|
|
$list['order.status.parentid'] = $this->getParentId(); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
return $list; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
} |
|
142
|
|
|
|