AddressFormatRepository.php in Address 8
File
src/Repository/AddressFormatRepository.php
View source
<?php
namespace Drupal\address\Repository;
use CommerceGuys\Addressing\AddressFormat\AddressFormatRepository as ExternalAddressFormatRepository;
use Drupal\address\Event\AddressEvents;
use Drupal\address\Event\AddressFormatEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class AddressFormatRepository extends ExternalAddressFormatRepository {
protected $eventDispatcher;
public function __construct(EventDispatcherInterface $event_dispatcher) {
$this->eventDispatcher = $event_dispatcher;
}
protected function processDefinition($countryCode, array $definition) {
$definition = parent::processDefinition($countryCode, $definition);
$event = new AddressFormatEvent($definition);
$this->eventDispatcher
->dispatch(AddressEvents::ADDRESS_FORMAT, $event);
$definition = $event
->getDefinition();
return $definition;
}
}