Skip to content

Commit 41b489a

Browse files
committed
Unset all order related objects from data array for backwards compatibility
1 parent 4904ea6 commit 41b489a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/MShop/Order/Item/Base.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,13 @@ abstract class Base
163163
*/
164164
public function __construct( string $prefix, array $values = [] )
165165
{
166-
parent::__construct( $prefix, $values );
167-
168166
$this->customer = $values['.customer'] ?? null;
169167
$this->locale = $values['.locale'];
170168
$this->price = $values['.price'];
171169

172-
$products = $this->get( '.products', [] );
170+
$products = $values['.products'] ?? [];
173171

174-
foreach( $this->get( '.coupons', [] ) as $coupon )
172+
foreach( $values['.coupons'] ?? [] as $coupon )
175173
{
176174
if( !isset( $this->coupons[$coupon->getCode()] ) ) {
177175
$this->coupons[$coupon->getCode()] = [];
@@ -182,21 +180,26 @@ public function __construct( string $prefix, array $values = [] )
182180
}
183181
}
184182

185-
foreach( $this->get( '.products', [] ) as $product ) {
183+
foreach( $values['.products'] ?? [] as $product ) {
186184
$this->products[$product->getPosition()] = $product;
187185
}
188186

189-
foreach( $this->get( '.addresses', [] ) as $address ) {
187+
foreach( $values['.addresses'] ?? [] as $address ) {
190188
$this->addresses[$address->getType()][] = $address;
191189
}
192190

193-
foreach( $this->get( '.services', [] ) as $service ) {
191+
foreach($values['.services'] ?? [] as $service ) {
194192
$this->services[$service->getType()][] = $service;
195193
}
196194

197-
foreach( $this->get( '.statuses', [] ) as $status ) {
195+
foreach( $values['.statuses'] ?? [] as $status ) {
198196
$this->statuses[$status->getType()][$status->getValue()] = $status;
199197
}
198+
199+
unset( $values['.customer'], $values['.locale'], $values['.price'], $values['.statuses'] );
200+
unset( $values['.products'], $values['.coupons'], $values['.addresses'], $values['.services'] );
201+
202+
parent::__construct( $prefix, $values );
200203
}
201204

202205

@@ -936,7 +939,7 @@ public function getTaxes() : array
936939
*/
937940
public function locale() : \Aimeos\MShop\Locale\Item\Iface
938941
{
939-
return $this->get( '.locale' );
942+
return $this->locale;
940943
}
941944

942945

@@ -950,7 +953,7 @@ public function locale() : \Aimeos\MShop\Locale\Item\Iface
950953
public function setLocale( \Aimeos\MShop\Locale\Item\Iface $locale ) : \Aimeos\MShop\Order\Item\Iface
951954
{
952955
$this->notify( 'setLocale.before', $locale );
953-
$this->set( '.locale', clone $locale );
956+
$this->locale = clone $locale;
954957
$this->notify( 'setLocale.after', $locale );
955958

956959
return parent::setModified();

0 commit comments

Comments
 (0)