NumberFormatRepository.php in Price 3.0.x
File
src/Repository/NumberFormatRepository.php
View source
<?php
namespace Drupal\price\Repository;
use CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface;
use CommerceGuys\Intl\NumberFormat\NumberFormatRepository as ExternalNumberFormatRepository;
use Drupal\price\Event\NumberFormatDefinitionEvent;
use Drupal\price\Event\PriceEvents;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class NumberFormatRepository extends ExternalNumberFormatRepository implements NumberFormatRepositoryInterface {
protected $eventDispatcher;
public function __construct(EventDispatcherInterface $event_dispatcher) {
parent::__construct();
$this->eventDispatcher = $event_dispatcher;
}
protected function processDefinition($locale, array $definition) {
$definition = parent::processDefinition($locale, $definition);
$event = new NumberFormatDefinitionEvent($definition);
$this->eventDispatcher
->dispatch(PriceEvents::NUMBER_FORMAT, $event);
$definition = $event
->getDefinition();
return $definition;
}
}