public function __construct(PricingProvider $p) { $cfg = new Config(); $this->currencyMeta = $cfg->getCurrencyMeta(); $this->pricingProvider = $p; $this->loadCache(); }
public function getPricingErrors(array $normalized) { $i18n = Localization::getTranslator(); $pricingSettings = []; $cfg = new Config(); $priceMSG = null; try { $price = ServiceLocater::resolve($normalized, 'PricingProvider')->getPrice(); if (!is_numeric($price->get())) { $pricingSettings[] = ['id' => '#sources-methods-error', 'error' => $i18n->_('Unknown format encountered:') . ' "' . $price . '".']; } $priceMSG = $i18n->_('Current Price would be: ') . $cfg->getCurrencyMeta()->format($price); } catch (Exception $e) { $pricingSettings[] = ['id' => '#sources-methods-error', 'error' => $e->getMessage()]; } return ['errors' => $pricingSettings, 'price' => $priceMSG]; }