class AddressTestEventSubscriber in Address 8
Subscribes to Address events for testing.
Hierarchy
- class \Drupal\address_test\EventSubscriber\AddressTestEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of AddressTestEventSubscriber
See also
\Drupal\Tests\address\FunctionalJavascript\AddressDefaultWidgetTest::testEvents()
1 string reference to 'AddressTestEventSubscriber'
- address_test.services.yml in tests/
modules/ address_test/ address_test.services.yml - tests/modules/address_test/address_test.services.yml
1 service uses AddressTestEventSubscriber
- address_test.event_subscriber in tests/
modules/ address_test/ address_test.services.yml - Drupal\address_test\EventSubscriber\AddressTestEventSubscriber
File
- tests/
modules/ address_test/ src/ EventSubscriber/ AddressTestEventSubscriber.php, line 14
Namespace
Drupal\address_test\EventSubscriberView source
class AddressTestEventSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AddressEvents::AVAILABLE_COUNTRIES][] = [
'onAvailableCountries',
];
return $events;
}
/**
* Alters the available countries.
*
* @param \Drupal\address\Event\AvailableCountriesEvent $event
* The available countries event.
*/
public function onAvailableCountries(AvailableCountriesEvent $event) {
$event
->setAvailableCountries($this
->getAvailableCountries());
}
/**
* Generates a set of available countries.
*
* @return array
* The countries.
*/
public function getAvailableCountries() {
return [
'AU' => 'AU',
'BR' => 'BR',
'CA' => 'CA',
'GB' => 'GB',
'US' => 'US',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AddressTestEventSubscriber:: |
public | function | Generates a set of available countries. | |
AddressTestEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
AddressTestEventSubscriber:: |
public | function | Alters the available countries. |