Skip to content

Commit

Permalink
Fix parcel sealing in Contao 4.13 (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar authored Jul 5, 2024
1 parent 86388e4 commit edc07e8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/NotificationCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,21 +298,25 @@ public function sendParcel(Parcel $parcel, string|null $gatewayName = null): Rec
*/
public function sealParcel(GatewayInterface $gateway, Parcel $parcel): Parcel
{
if ($parcel->isSealed() || null === $this->localeSwitcher) {
return $parcel;
}

/** @var LocaleStamp|null $localeStamp */
$localeStamp = $parcel->getStamp(LocaleStamp::class);
$locale = $localeStamp?->locale;

$seal = static function () use ($gateway, $parcel): Parcel {
if ($parcel->isSealed()) {
return $parcel;
}

$parcel = $gateway->sealParcel($parcel);

// Gateways are expected to seal but let's be very sure it is
return $parcel->seal();
};

if (null === $this->localeSwitcher) {
return $seal();
}

/** @var LocaleStamp|null $localeStamp */
$localeStamp = $parcel->getStamp(LocaleStamp::class);
$locale = $localeStamp?->locale;

if (null === $locale) {
return $seal();
}
Expand Down

0 comments on commit edc07e8

Please sign in to comment.