public function GreatBritainEventSubscriber::onAddressFormat in Address 8
Alters the address format for Great Britain.
Parameters
\Drupal\address\Event\AddressFormatEvent $event: The address format event.
File
- tests/
modules/ address_test/ src/ EventSubscriber/ GreatBritainEventSubscriber.php, line 34
Class
- GreatBritainEventSubscriber
- Adds a county field and a predefined list of counties for Great Britain.
Namespace
Drupal\address_test\EventSubscriberCode
public function onAddressFormat(AddressFormatEvent $event) {
$definition = $event
->getDefinition();
if ($definition['country_code'] == 'GB') {
$definition['format'] = $definition['format'] . "\n%administrativeArea";
$definition['administrative_area_type'] = AdministrativeAreaType::COUNTY;
$definition['subdivision_depth'] = 1;
$event
->setDefinition($definition);
}
}