Skip to content

Commit

Permalink
Unset all order related objects from data array for backwards compati…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
aimeos committed Dec 2, 2024
1 parent 4904ea6 commit 41b489a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/MShop/Order/Item/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,13 @@ abstract class Base
*/
public function __construct( string $prefix, array $values = [] )
{
parent::__construct( $prefix, $values );

$this->customer = $values['.customer'] ?? null;
$this->locale = $values['.locale'];
$this->price = $values['.price'];

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

foreach( $this->get( '.coupons', [] ) as $coupon )
foreach( $values['.coupons'] ?? [] as $coupon )
{
if( !isset( $this->coupons[$coupon->getCode()] ) ) {
$this->coupons[$coupon->getCode()] = [];
Expand All @@ -182,21 +180,26 @@ public function __construct( string $prefix, array $values = [] )
}
}

foreach( $this->get( '.products', [] ) as $product ) {
foreach( $values['.products'] ?? [] as $product ) {
$this->products[$product->getPosition()] = $product;
}

foreach( $this->get( '.addresses', [] ) as $address ) {
foreach( $values['.addresses'] ?? [] as $address ) {
$this->addresses[$address->getType()][] = $address;
}

foreach( $this->get( '.services', [] ) as $service ) {
foreach($values['.services'] ?? [] as $service ) {
$this->services[$service->getType()][] = $service;
}

foreach( $this->get( '.statuses', [] ) as $status ) {
foreach( $values['.statuses'] ?? [] as $status ) {
$this->statuses[$status->getType()][$status->getValue()] = $status;
}

unset( $values['.customer'], $values['.locale'], $values['.price'], $values['.statuses'] );
unset( $values['.products'], $values['.coupons'], $values['.addresses'], $values['.services'] );

parent::__construct( $prefix, $values );
}


Expand Down Expand Up @@ -936,7 +939,7 @@ public function getTaxes() : array
*/
public function locale() : \Aimeos\MShop\Locale\Item\Iface
{
return $this->get( '.locale' );
return $this->locale;
}


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

return parent::setModified();
Expand Down

0 comments on commit 41b489a

Please sign in to comment.