/**
  * 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());
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(['currency' => $this->currencyContext->getCurrency()]);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('currency' => $this->currencyContext->getCurrency()));
 }
Example #5
0
 function it_provides_current_currency(CurrencyContextInterface $currencyContext)
 {
     $currencyContext->getCurrency()->willReturn('PLN');
     $this->getCurrentCurrencySymbol()->shouldReturn('PLN');
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 protected function getDefaultCurrency()
 {
     return $this->currencyContext->getCurrency();
 }
Example #7
0
 /**
  * @return string
  */
 public function getCurrentCurrencySymbol()
 {
     return Intl::getCurrencyBundle()->getCurrencySymbol($this->currencyContext->getCurrency());
 }