public function setDefault(CurrencyUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
            // Reset default status
            CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDefault' => false));

            $currency
                ->setDispatcher($dispatcher)
                ->setVisible($event->getVisible())
                ->setByDefault($event->getIsDefault())
                ->save()
            ;

            // Update rates when setting a new default currency
            if ($event->getIsDefault()) {
                $updateRateEvent = new CurrencyUpdateRateEvent();

                $dispatcher->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES, $updateRateEvent);
            }

            $event->setCurrency($currency);
        }
    }
public function setDefault(CurrencyUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
    {
        if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
            // Reset default status
            CurrencyQuery::create()->filterByByDefault(true)->update(array('ByDefault' => false));

            $currency
                ->setDispatcher($dispatcher)
                ->setVisible($event->getVisible())
                ->setByDefault($event->getIsDefault())
                ->save()
            ;

            // Update rates when setting a new default currency
            if ($event->getIsDefault()) {
                $updateRateEvent = new CurrencyUpdateRateEvent();

                $dispatcher->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES, $updateRateEvent);
            }

            $event->setCurrency($currency);
        }
    }
public function setDefault ( CurrencyUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) { // Reset default status CurrencyQuery :: create ( ) -> filterByByDefault ( true ) -> update ( array ( 'ByDefault' => false ) ) ; $ currency -> setDispatcher ( $ dispatcher ) -> setVisible ( $ event -> getVisible ( ) ) -> setByDefault ( $ event -> getIsDefault ( ) ) -> save ( ) ; // Update rates when setting a new default currency if ( $ event -> getIsDefault ( ) ) { $ updateRateEvent = new CurrencyUpdateRateEvent ( ) ; $ dispatcher -> dispatch ( TheliaEvents :: CURRENCY_UPDATE_RATES , $ updateRateEvent ) ; } $ event -> setCurrency ( $ currency ) ; } }
Set the default currency

@param CurrencyUpdateEvent $event
@param $eventName
@param EventDispatcherInterface $dispatcher
Set the default currency