You are here

class NumberFormatRepository in Price 3.x

Same name and namespace in other branches
  1. 8 src/Repository/NumberFormatRepository.php \Drupal\price\Repository\NumberFormatRepository
  2. 2.0.x src/Repository/NumberFormatRepository.php \Drupal\price\Repository\NumberFormatRepository
  3. 2.x src/Repository/NumberFormatRepository.php \Drupal\price\Repository\NumberFormatRepository
  4. 3.0.x src/Repository/NumberFormatRepository.php \Drupal\price\Repository\NumberFormatRepository

Defines the number format repository.

Number formats are stored inside the parent class, which is extended here to allow the definitions to be altered via events.

Hierarchy

  • class \Drupal\price\Repository\NumberFormatRepository extends \CommerceGuys\Intl\NumberFormat\NumberFormatRepository implements \CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface

Expanded class hierarchy of NumberFormatRepository

1 string reference to 'NumberFormatRepository'
price.services.yml in ./price.services.yml
price.services.yml
1 service uses NumberFormatRepository
price.number_format_repository in ./price.services.yml
Drupal\price\Repository\NumberFormatRepository

File

src/Repository/NumberFormatRepository.php, line 17

Namespace

Drupal\price\Repository
View source
class NumberFormatRepository extends ExternalNumberFormatRepository implements NumberFormatRepositoryInterface {

  /**
   * The event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $eventDispatcher;

  /**
   * Creates a NumberFormatRepository instance.
   *
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
   *   The event dispatcher.
   */
  public function __construct(EventDispatcherInterface $event_dispatcher) {
    parent::__construct();
    $this->eventDispatcher = $event_dispatcher;
  }

  /**
   * {@inheritdoc}
   */
  protected function processDefinition($locale, array $definition) {
    $definition = parent::processDefinition($locale, $definition);

    // Let the definition be altered.
    $event = new NumberFormatDefinitionEvent($definition);
    $this->eventDispatcher
      ->dispatch(PriceEvents::NUMBER_FORMAT, $event);
    $definition = $event
      ->getDefinition();
    return $definition;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NumberFormatRepository::$eventDispatcher protected property The event dispatcher.
NumberFormatRepository::processDefinition protected function
NumberFormatRepository::__construct public function Creates a NumberFormatRepository instance.