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