platform/src/Core/System/Currency/CurrencyLoadSubscriber.php line 16

Open in your IDE?
  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 Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class CurrencyLoadSubscriber implements EventSubscriberInterface
  7. {
  8.     public static function getSubscribedEvents(): array
  9.     {
  10.         return [CurrencyEvents::CURRENCY_LOADED_EVENT => 'setDefault'];
  11.     }
  12.     public function setDefault(EntityLoadedEvent $event): void
  13.     {
  14.         /** @var CurrencyEntity $entity */
  15.         foreach ($event->getEntities() as $entity) {
  16.             $entity->setIsSystemDefault($entity->getId() === Defaults::CURRENCY);
  17.         }
  18.     }
  19. }