/** * Sets currency on the order * * @throws UnexpectedTypeException when event's subject is not an order * * @param GenericEvent $event */ public function processOrderCurrency(GenericEvent $event) { $order = $event->getSubject(); if (!$order instanceof OrderInterface) { throw new UnexpectedTypeException($order, OrderInterface::class); } $order->setCurrency($this->currencyContext->getCurrency()); }
/** * Convert amount and format it! * * @param int $amount * @param string|null $currency * @param bool $decimal * * @return string */ public function convertAndFormatAmount($amount, $currency = null, $decimal = false) { $currency = $currency ?: $this->currencyContext->getCurrency(); $amount = $this->converter->convertFromBase($amount, $currency); return $this->moneyHelper->formatAmount($amount, $currency, $decimal); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(['currency' => $this->currencyContext->getCurrency()]); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('currency' => $this->currencyContext->getCurrency())); }
function it_provides_current_currency(CurrencyContextInterface $currencyContext) { $currencyContext->getCurrency()->willReturn('PLN'); $this->getCurrentCurrencySymbol()->shouldReturn('PLN'); }
/** * {@inheritdoc} */ protected function getDefaultCurrency() { return $this->currencyContext->getCurrency(); }
/** * @return string */ public function getCurrentCurrencySymbol() { return Intl::getCurrencyBundle()->getCurrencySymbol($this->currencyContext->getCurrency()); }