Commit 754299f6 authored by Luhur Abdi Rizal's avatar Luhur Abdi Rizal
Browse files

Issue #3263299 by el7cosmos: Move events constant from interface to a class

parent 68ceb417
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Drupal\hook_event_dispatcher;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\core_event_dispatcher\Event\Form\FormBaseAlterEvent;
use Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent;
use Drupal\core_event_dispatcher\FormHookEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
@@ -63,7 +64,7 @@ class ExampleFormEventSubscribers implements EventSubscriberInterface {
   */
  public static function getSubscribedEvents(): array {
    return [
      HookEventDispatcherInterface::FORM_ALTER => 'alterForm',
      FormHookEvents::FORM_ALTER => 'alterForm',
      // React on "search_block_form" form.
      'hook_event_dispatcher.form_search_block_form.alter' => 'alterSearchForm',
      // React on al forms with base id "node_form".
+3 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Drupal\hook_event_dispatcher;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\core_event_dispatcher\Event\Token\TokensInfoEvent;
use Drupal\core_event_dispatcher\Event\Token\TokensReplacementEvent;
use Drupal\core_event_dispatcher\TokenHookEvents;
use Drupal\core_event_dispatcher\ValueObject\Token;
use Drupal\core_event_dispatcher\ValueObject\TokenType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -28,8 +29,8 @@ final class ExampleTokenEventSubscriber implements EventSubscriberInterface {
   */
  public static function getSubscribedEvents(): array {
    return [
      HookEventDispatcherInterface::TOKEN_REPLACEMENT => 'tokenReplacement',
      HookEventDispatcherInterface::TOKEN_INFO => 'tokenInfo',
      TokenHookEvents::TOKEN_REPLACEMENT => 'tokenReplacement',
      TokenHookEvents::TOKEN_INFO => 'tokenInfo',
    ];
  }

+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\core_event_dispatcher\Event\Form;

use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\core_event_dispatcher\FormHookEvents;

/**
 * Class FormAlterEvent.
@@ -13,7 +13,7 @@ class FormAlterEvent extends AbstractFormEvent {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::FORM_ALTER;
    return FormHookEvents::FORM_ALTER;
  }

}
+5 −3
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@

namespace Drupal\core_event_dispatcher\Event\Language;

use Drupal\Component\EventDispatcher\Event;
use Drupal\Core\Url;
use Drupal\core_event_dispatcher\LanguageHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\Component\EventDispatcher\Event;

/**
 * Class LanguageSwitchLinksAlterEvent.
@@ -18,12 +18,14 @@ class LanguageSwitchLinksAlterEvent extends Event implements EventInterface {
   * @var array
   */
  private $links;

  /**
   * The language type.
   *
   * @var string
   */
  private $type;

  /**
   * The request path.
   *
@@ -93,7 +95,7 @@ class LanguageSwitchLinksAlterEvent extends Event implements EventInterface {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::LANGUAGE_SWITCH_LINKS_ALTER;
    return LanguageHookEvents::LANGUAGE_SWITCH_LINKS_ALTER;
  }

}
+3 −3
Original line number Diff line number Diff line
@@ -2,9 +2,9 @@

namespace Drupal\core_event_dispatcher\Event\Theme;

use Drupal\hook_event_dispatcher\Event\EventInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\Component\EventDispatcher\Event;
use Drupal\core_event_dispatcher\PageHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;

/**
 * Class PageAttachmentsEvent.
@@ -42,7 +42,7 @@ class PageAttachmentsEvent extends Event implements EventInterface {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::PAGE_ATTACHMENTS;
    return PageHookEvents::PAGE_ATTACHMENTS;
  }

}
Loading