You are here

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\EventSubscriber
View 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

Namesort descending Modifiers Type Description Overrides
AddressTestEventSubscriber::getAvailableCountries public function Generates a set of available countries.
AddressTestEventSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
AddressTestEventSubscriber::onAvailableCountries public function Alters the available countries.