src/Core/System/Currency/CurrencyLoadSubscriber.php line 24

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\System\Currency;
  3. use Shopware\Core\Defaults;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
  5. use Shopware\Core\Framework\Log\Package;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. /**
  8.  * @internal
  9.  */
  10. #[Package('core')]
  11. class CurrencyLoadSubscriber implements EventSubscriberInterface
  12. {
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             CurrencyEvents::CURRENCY_LOADED_EVENT => 'setDefault',
  17.             'currency.partial_loaded' => 'setDefault',
  18.         ];
  19.     }
  20.     public function setDefault(EntityLoadedEvent $event): void
  21.     {
  22.         foreach ($event->getEntities() as $entity) {
  23.             $entity->assign([
  24.                 'isSystemDefault' => ($entity->get('id') === Defaults::CURRENCY),
  25.             ]);
  26.         }
  27.     }
  28. }