Commit 716d6cd9 authored by Luhur Abdi Rizal's avatar Luhur Abdi Rizal
Browse files

Issue #3265143 by el7cosmos: Move theme hook event constants to a class

parent f52cb547
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@

namespace Drupal\core_event_dispatcher\Event\Theme;

use Drupal\Component\EventDispatcher\Event;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\core_event_dispatcher\ThemeHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\Component\EventDispatcher\Event;

/**
 * Class JsAlterEvent.
@@ -69,7 +69,7 @@ final class JsAlterEvent extends Event implements EventInterface {
   *   The dispatcher type.
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::JS_ALTER;
    return ThemeHookEvents::JS_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\ThemeHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;

/**
 * Class LibraryInfoAlterEvent.
@@ -64,7 +64,7 @@ class LibraryInfoAlterEvent extends Event implements EventInterface {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::LIBRARY_INFO_ALTER;
    return ThemeHookEvents::LIBRARY_INFO_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\ThemeHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;

/**
 * Class TemplatePreprocessDefaultVariablesAlterEvent.
@@ -38,7 +38,7 @@ final class TemplatePreprocessDefaultVariablesAlterEvent extends Event implement
   *   The dispatcher type.
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::TEMPLATE_PREPROCESS_DEFAULT_VARIABLES_ALTER;
    return ThemeHookEvents::TEMPLATE_PREPROCESS_DEFAULT_VARIABLES_ALTER;
  }

  /**
+6 −5
Original line number Diff line number Diff line
@@ -2,10 +2,10 @@

namespace Drupal\core_event_dispatcher\Event\Theme;

use Drupal\Component\EventDispatcher\Event;
use Drupal\core_event_dispatcher\ThemeHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use RuntimeException;
use Drupal\Component\EventDispatcher\Event;

/**
 * Class ThemeEvent.
@@ -18,6 +18,7 @@ final class ThemeEvent extends Event implements EventInterface {
   * @var array
   */
  private $existing;

  /**
   * Added themes.
   *
@@ -47,7 +48,7 @@ final class ThemeEvent extends Event implements EventInterface {
   *   The dispatcher type.
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::THEME;
    return ThemeHookEvents::THEME;
  }

  /**
@@ -83,7 +84,7 @@ final class ThemeEvent extends Event implements EventInterface {
   *
   * @throws \RuntimeException
   */
  public function addNewTheme($theme, array $information) {
  public function addNewTheme(string $theme, array $information): void {
    if (empty($information['path'])) {
      throw new RuntimeException(
        'Missing path in the information array. ThemeEvent needs the path to be set manually, to have a proper default theme implementation. See \hook_theme() for more information.'
@@ -103,7 +104,7 @@ final class ThemeEvent extends Event implements EventInterface {
   *
   * @throws \RuntimeException
   */
  public function addNewThemes(array $themes) {
  public function addNewThemes(array $themes): void {
    foreach ($themes as $theme => $information) {
      $this->addNewTheme($theme, $information);
    }
+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\ThemeHookEvents;
use Drupal\hook_event_dispatcher\Event\EventInterface;

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

}
Loading