Commit 2be4c749 authored by Luhur Abdi Rizal's avatar Luhur Abdi Rizal
Browse files

Issue #3265437 by el7cosmos: Move block hook event constants to a class

parent 9451a785
Loading
Loading
Loading
Loading
+64 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\core_event_dispatcher;

use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;

/**
 * Defines events for block hooks.
 */
class BlockHookEvents {

  /**
   * Alter the result of \Drupal\Core\Block\BlockBase::build().
   *
   * @Event
   *
   * @see \Drupal\core_event_dispatcher\Event\Block\BlockViewAlterEvent
   * @see core_event_dispatcher_block_view_alter()
   * @see hook_block_view_alter()
   *
   * @var string
   */
  public const BLOCK_VIEW_ALTER = HookEventDispatcherInterface::PREFIX . 'block_view.alter';

  /**
   * Alter the result of \Drupal\Core\Block\BlockBase::build().
   *
   * @Event
   *
   * @see \Drupal\core_event_dispatcher\Event\Block\BlockBuildAlterEvent
   * @see core_event_dispatcher_block_build_alter()
   * @see hook_block_build_alter()
   *
   * @var string
   */
  public const BLOCK_BUILD_ALTER = HookEventDispatcherInterface::PREFIX . 'block_build.alter';

  /**
   * Control access to a block instance.
   *
   * @Event
   *
   * @see \Drupal\core_event_dispatcher\Event\Block\BlockAccessEvent
   * @see core_event_dispatcher_block_access()
   * @see hook_block_access()
   *
   * @var string
   */
  public const BLOCK_ACCESS = HookEventDispatcherInterface::PREFIX . 'block.access';

  /**
   * Allow modules to alter the block plugin definitions.
   *
   * @Event
   *
   * @see \Drupal\core_event_dispatcher\Event\Block\BlockAlterEvent
   * @see core_event_dispatcher_block_alter()
   * @see hook_block_alter()
   *
   * @var string
   */
  public const BLOCK_ALTER = HookEventDispatcherInterface::PREFIX . 'block.alter';

}
+2 −2
Original line number Diff line number Diff line
@@ -6,10 +6,10 @@ use Drupal\block\BlockInterface;
use Drupal\Component\EventDispatcher\Event;
use Drupal\Core\Access\AccessResultNeutral;
use Drupal\Core\Session\AccountInterface;
use Drupal\core_event_dispatcher\BlockHookEvents;
use Drupal\hook_event_dispatcher\Event\AccessEventInterface;
use Drupal\hook_event_dispatcher\Event\AccessEventTrait;
use Drupal\hook_event_dispatcher\Event\EventInterface;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;

/**
 * Class BlockAccessEvent.
@@ -49,7 +49,7 @@ class BlockAccessEvent extends Event implements EventInterface, AccessEventInter
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::BLOCK_ACCESS;
    return BlockHookEvents::BLOCK_ACCESS;
  }

}
+2 −2
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

namespace Drupal\core_event_dispatcher\Event\Block;

use Drupal\core_event_dispatcher\BlockHookEvents;
use Drupal\hook_event_dispatcher\Event\PluginDefinitionAlterEventBase;
use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;

/**
 * Class BlockAlterEvent.
@@ -14,7 +14,7 @@ class BlockAlterEvent extends PluginDefinitionAlterEventBase {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::BLOCK_ALTER;
    return BlockHookEvents::BLOCK_ALTER;
  }

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

namespace Drupal\core_event_dispatcher\Event\Block;

use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\core_event_dispatcher\BlockHookEvents;

/**
 * Class BlockBuildAlterEvent.
@@ -13,7 +13,7 @@ class BlockBuildAlterEvent extends BlockViewBuilderAlterEventBase {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::BLOCK_BUILD_ALTER;
    return BlockHookEvents::BLOCK_BUILD_ALTER;
  }

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

namespace Drupal\core_event_dispatcher\Event\Block;

use Drupal\hook_event_dispatcher\HookEventDispatcherInterface;
use Drupal\core_event_dispatcher\BlockHookEvents;

/**
 * Class BlockViewAlterEvent.
@@ -13,7 +13,7 @@ class BlockViewAlterEvent extends BlockViewBuilderAlterEventBase {
   * {@inheritdoc}
   */
  public function getDispatcherType(): string {
    return HookEventDispatcherInterface::BLOCK_VIEW_ALTER;
    return BlockHookEvents::BLOCK_VIEW_ALTER;
  }

}
Loading