You are here

public static function EventSubscriber::getSubscribedEvents in Scheduler 2.x

Same name and namespace in other branches
  1. 8 tests/modules/scheduler_api_test/src/EventSubscriber.php \Drupal\scheduler_api_test\EventSubscriber::getSubscribedEvents()

File

tests/modules/scheduler_api_test/src/EventSubscriber.php, line 37

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public static function getSubscribedEvents() {

  // Initialise the array to avoid 'variable is undefined' phpcs error.
  $events = [];

  // The values in the arrays give the function names below.
  // These six events are the originals, dispatched for Nodes.
  $events[SchedulerNodeEvents::PRE_PUBLISH][] = [
    'apiTestNodePrePublish',
  ];
  $events[SchedulerNodeEvents::PUBLISH][] = [
    'apiTestNodePublish',
  ];
  $events[SchedulerNodeEvents::PRE_UNPUBLISH][] = [
    'apiTestNodePreUnpublish',
  ];
  $events[SchedulerNodeEvents::UNPUBLISH][] = [
    'apiTestNodeUnpublish',
  ];
  $events[SchedulerNodeEvents::PRE_PUBLISH_IMMEDIATELY][] = [
    'apiTestNodePrePublishImmediately',
  ];
  $events[SchedulerNodeEvents::PUBLISH_IMMEDIATELY][] = [
    'apiTestNodePublishImmediately',
  ];

  // These six events are dispatched for Media entity types only.
  $events[SchedulerMediaEvents::PRE_PUBLISH][] = [
    'apiTestMediaPrePublish',
  ];
  $events[SchedulerMediaEvents::PUBLISH][] = [
    'apiTestMediaPublish',
  ];
  $events[SchedulerMediaEvents::PRE_UNPUBLISH][] = [
    'apiTestMediaPreUnpublish',
  ];
  $events[SchedulerMediaEvents::UNPUBLISH][] = [
    'apiTestMediaUnpublish',
  ];
  $events[SchedulerMediaEvents::PRE_PUBLISH_IMMEDIATELY][] = [
    'apiTestMediaPrePublishImmediately',
  ];
  $events[SchedulerMediaEvents::PUBLISH_IMMEDIATELY][] = [
    'apiTestMediaPublishImmediately',
  ];

  // These six events are dispatched for Product entity types only.
  $events[SchedulerCommerceproductEvents::PRE_PUBLISH][] = [
    'apiTestProductPrePublish',
  ];
  $events[SchedulerCommerceproductEvents::PUBLISH][] = [
    'apiTestProductPublish',
  ];
  $events[SchedulerCommerceproductEvents::PRE_UNPUBLISH][] = [
    'apiTestProductPreUnpublish',
  ];
  $events[SchedulerCommerceproductEvents::UNPUBLISH][] = [
    'apiTestProductUnpublish',
  ];
  $events[SchedulerCommerceproductEvents::PRE_PUBLISH_IMMEDIATELY][] = [
    'apiTestProductPrePublishImmediately',
  ];
  $events[SchedulerCommerceproductEvents::PUBLISH_IMMEDIATELY][] = [
    'apiTestProductPublishImmediately',
  ];
  return $events;
}