Loading modules/core_event_dispatcher/core_event_dispatcher.module +22 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ use Drupal\core_event_dispatcher\Event\Block\BlockAccessEvent; use Drupal\core_event_dispatcher\Event\Block\BlockAlterEvent; use Drupal\core_event_dispatcher\Event\Block\BlockBuildAlterEvent; use Drupal\core_event_dispatcher\Event\Block\BlockViewAlterEvent; use Drupal\core_event_dispatcher\Event\Core\CacheFlushEvent; use Drupal\core_event_dispatcher\Event\Core\CountriesAlterEvent; use Drupal\core_event_dispatcher\Event\Core\CronEvent; use Drupal\core_event_dispatcher\Event\Core\DataTypeInfoAlterEvent; Loading @@ -30,6 +31,7 @@ use Drupal\core_event_dispatcher\Event\Core\LayoutAlterEvent; use Drupal\core_event_dispatcher\Event\Core\MailAlterEvent; use Drupal\core_event_dispatcher\Event\Core\MailBackendInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Core\QueueInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Core\RebuildEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityAccessEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityBaseFieldInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityBaseFieldInfoEvent; Loading Loading @@ -73,8 +75,6 @@ use Drupal\core_event_dispatcher\Event\Language\LanguageSwitchLinksAlterEvent; // Core. // @todo hook_mail() // @todo hook_cache_flush() // @todo hook_rebuild() // @todo hook_config_import_steps_alter() // @todo hook_config_schema_info_alter() // @todo hook_validation_constraint_alter() Loading Loading @@ -249,6 +249,26 @@ function core_event_dispatcher_layout_alter(array &$definitions) { $manager->register($event); } /** * Implements hook_cache_flush(). */ function core_event_dispatcher_cache_flush() { /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */ $manager = Drupal::service('hook_event_dispatcher.manager'); $event = new CacheFlushEvent(); $manager->register($event); } /** * Implements hook_rebuild(). */ function core_event_dispatcher_rebuild() { /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */ $manager = Drupal::service('hook_event_dispatcher.manager'); $event = new RebuildEvent(); $manager->register($event); } /** * Implements hook_entity_access(). * Loading modules/core_event_dispatcher/src/Event/Core/CacheFlushEvent.php 0 → 100644 +21 −0 Original line number Diff line number Diff line <?php namespace Drupal\core_event_dispatcher\Event\Core; use Drupal\Component\EventDispatcher\Event; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Class CacheFlushEvent. */ class CacheFlushEvent extends Event implements EventInterface { /** * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::CACHE_FLUSH; } } modules/core_event_dispatcher/src/Event/Core/RebuildEvent.php 0 → 100644 +21 −0 Original line number Diff line number Diff line <?php namespace Drupal\core_event_dispatcher\Event\Core; use Drupal\Component\EventDispatcher\Event; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Class RebuildEvent. */ class RebuildEvent extends Event implements EventInterface { /** * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::REBUILD; } } modules/core_event_dispatcher/tests/src/Kernel/Core/CacheFlushEventTest.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\core_event_dispatcher\Kernel\Core; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; /** * Class CacheFlushEventTest. * * @group hook_event_dispatcher * @group core_event_dispatcher * * @see core_event_dispatcher_cache_flush() */ class CacheFlushEventTest extends KernelTestBase { use ListenerTrait; /** * {@inheritdoc} */ protected static $modules = [ 'hook_event_dispatcher', 'core_event_dispatcher', ]; /** * Test the cache flush event. * * @throws \Exception */ public function testCacheFlushEvent(): void { $this->listen(HookEventDispatcherInterface::CACHE_FLUSH, 'onCacheFlush'); $this->container->get('module_handler')->invokeAll('cache_flush'); } /** * Callback for CacheFlushEvent. */ public function onCacheFlush(): void { } } modules/core_event_dispatcher/tests/src/Kernel/Core/RebuildEventTest.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\core_event_dispatcher\Kernel\Core; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; /** * Class RebuildEventTest. * * @group hook_event_dispatcher * @group core_event_dispatcher * * @see core_event_dispatcher_rebuild() */ class RebuildEventTest extends KernelTestBase { use ListenerTrait; /** * {@inheritdoc} */ protected static $modules = [ 'hook_event_dispatcher', 'core_event_dispatcher', ]; /** * Test the rebuild event. * * @throws \Exception */ public function testRebuildEvent(): void { $this->listen(HookEventDispatcherInterface::REBUILD, 'onRebuild'); $this->container->get('module_handler')->invokeAll('rebuild'); } /** * Callback for RebuildEvent. */ public function onRebuild(): void { } } Loading
modules/core_event_dispatcher/core_event_dispatcher.module +22 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ use Drupal\core_event_dispatcher\Event\Block\BlockAccessEvent; use Drupal\core_event_dispatcher\Event\Block\BlockAlterEvent; use Drupal\core_event_dispatcher\Event\Block\BlockBuildAlterEvent; use Drupal\core_event_dispatcher\Event\Block\BlockViewAlterEvent; use Drupal\core_event_dispatcher\Event\Core\CacheFlushEvent; use Drupal\core_event_dispatcher\Event\Core\CountriesAlterEvent; use Drupal\core_event_dispatcher\Event\Core\CronEvent; use Drupal\core_event_dispatcher\Event\Core\DataTypeInfoAlterEvent; Loading @@ -30,6 +31,7 @@ use Drupal\core_event_dispatcher\Event\Core\LayoutAlterEvent; use Drupal\core_event_dispatcher\Event\Core\MailAlterEvent; use Drupal\core_event_dispatcher\Event\Core\MailBackendInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Core\QueueInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Core\RebuildEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityAccessEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityBaseFieldInfoAlterEvent; use Drupal\core_event_dispatcher\Event\Entity\EntityBaseFieldInfoEvent; Loading Loading @@ -73,8 +75,6 @@ use Drupal\core_event_dispatcher\Event\Language\LanguageSwitchLinksAlterEvent; // Core. // @todo hook_mail() // @todo hook_cache_flush() // @todo hook_rebuild() // @todo hook_config_import_steps_alter() // @todo hook_config_schema_info_alter() // @todo hook_validation_constraint_alter() Loading Loading @@ -249,6 +249,26 @@ function core_event_dispatcher_layout_alter(array &$definitions) { $manager->register($event); } /** * Implements hook_cache_flush(). */ function core_event_dispatcher_cache_flush() { /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */ $manager = Drupal::service('hook_event_dispatcher.manager'); $event = new CacheFlushEvent(); $manager->register($event); } /** * Implements hook_rebuild(). */ function core_event_dispatcher_rebuild() { /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */ $manager = Drupal::service('hook_event_dispatcher.manager'); $event = new RebuildEvent(); $manager->register($event); } /** * Implements hook_entity_access(). * Loading
modules/core_event_dispatcher/src/Event/Core/CacheFlushEvent.php 0 → 100644 +21 −0 Original line number Diff line number Diff line <?php namespace Drupal\core_event_dispatcher\Event\Core; use Drupal\Component\EventDispatcher\Event; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Class CacheFlushEvent. */ class CacheFlushEvent extends Event implements EventInterface { /** * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::CACHE_FLUSH; } }
modules/core_event_dispatcher/src/Event/Core/RebuildEvent.php 0 → 100644 +21 −0 Original line number Diff line number Diff line <?php namespace Drupal\core_event_dispatcher\Event\Core; use Drupal\Component\EventDispatcher\Event; use Drupal\hook_event_dispatcher\Event\EventInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Class RebuildEvent. */ class RebuildEvent extends Event implements EventInterface { /** * {@inheritdoc} */ public function getDispatcherType(): string { return HookEventDispatcherInterface::REBUILD; } }
modules/core_event_dispatcher/tests/src/Kernel/Core/CacheFlushEventTest.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\core_event_dispatcher\Kernel\Core; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; /** * Class CacheFlushEventTest. * * @group hook_event_dispatcher * @group core_event_dispatcher * * @see core_event_dispatcher_cache_flush() */ class CacheFlushEventTest extends KernelTestBase { use ListenerTrait; /** * {@inheritdoc} */ protected static $modules = [ 'hook_event_dispatcher', 'core_event_dispatcher', ]; /** * Test the cache flush event. * * @throws \Exception */ public function testCacheFlushEvent(): void { $this->listen(HookEventDispatcherInterface::CACHE_FLUSH, 'onCacheFlush'); $this->container->get('module_handler')->invokeAll('cache_flush'); } /** * Callback for CacheFlushEvent. */ public function onCacheFlush(): void { } }
modules/core_event_dispatcher/tests/src/Kernel/Core/RebuildEventTest.php 0 → 100644 +46 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\core_event_dispatcher\Kernel\Core; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\hook_event_dispatcher\Kernel\ListenerTrait; /** * Class RebuildEventTest. * * @group hook_event_dispatcher * @group core_event_dispatcher * * @see core_event_dispatcher_rebuild() */ class RebuildEventTest extends KernelTestBase { use ListenerTrait; /** * {@inheritdoc} */ protected static $modules = [ 'hook_event_dispatcher', 'core_event_dispatcher', ]; /** * Test the rebuild event. * * @throws \Exception */ public function testRebuildEvent(): void { $this->listen(HookEventDispatcherInterface::REBUILD, 'onRebuild'); $this->container->get('module_handler')->invokeAll('rebuild'); } /** * Callback for RebuildEvent. */ public function onRebuild(): void { } }