/**
  * Return money formatter.
  *
  * <code>
  * $this->prepareMoneyFormatter($container, $params);
  * $money = $this->getMoneyFormatter($container, $params);
  * </code>
  *
  * @param Registry $params
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  *
  * @return Money
  */
 protected function getMoneyFormatter($params)
 {
     $currencyId = $params->get('project_currency');
     // Get the currency.
     $currency = $this->getCurrency($currencyId);
     // Prepare decimal pattern.
     $fractionDigits = (int) $params->get('fraction_digits', 2);
     $pattern = '#,##0';
     if ($fractionDigits > 0) {
         $pattern .= '.' . str_repeat('0', $fractionDigits);
     }
     $formatter = LocaleHelper::getNumberFormatter($pattern);
     $money = new Money($formatter);
     $money->setCurrency($currency);
     return $money;
 }
 /**
  * Prepare money formatter.
  *
  * <code>
  * $this->prepareMoneyFormatter($container, $params);
  * </code>
  *
  * @param Container $container
  * @param Registry $params
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  */
 protected function prepareMoneyFormatter($container, $params)
 {
     $currencyId = $params->get('project_currency');
     $moneyHash = StringHelper::generateMd5Hash(Constants::CONTAINER_FORMATTER_MONEY, $currencyId);
     if (!$container->exists($moneyHash)) {
         // Get the currency from the container.
         $currency = $this->getCurrency($container, $params);
         // Prepare decimal pattern.
         $fractionDigits = (int) $params->get('fraction_digits', 2);
         $pattern = '#,##0';
         if ($fractionDigits > 0) {
             $pattern .= '.' . str_repeat('0', $fractionDigits);
         }
         $formatter = LocaleHelper::getNumberFormatter($pattern);
         $money = new Money($formatter);
         $money->setCurrency($currency);
         $container->set($moneyHash, $money);
     }
 }