You are here

class MyEventSubscriber in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x scheduled_transitions.api.php \MyEventSubscriber

Event subscribers for Scheduled Transitions Field.

Define a service, e.g: <code> ```yaml my_module.my_event_subscriber: class: Drupal\my_module\EventSubscriber\MyEventSubscriber tags:

  • { name: event_subscriber }

``` </code>

Hierarchy

  • class \MyEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MyEventSubscriber

File

./scheduled_transitions.api.php, line 27

View source
class MyEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface {

  /**
   * Custom logic to determine new revision for a scheduled transition.
   *
   * @param \Drupal\scheduled_transitions\Event\ScheduledTransitionsNewRevisionEvent $event
   *   New revision event.
   */
  public function newRevision(\Drupal\scheduled_transitions\Event\ScheduledTransitionsNewRevisionEvent $event) : void {
    $scheduledTransition = $event
      ->getScheduledTransition();
    $entity = $scheduledTransition
      ->getEntity();
    $newRevision = $entity;
    $event
      ->setNewRevision($newRevision);
    $event
      ->stopPropagation();
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() : array {
    return [
      \Drupal\scheduled_transitions\Event\ScheduledTransitionsEvents::NEW_REVISION => [
        'newRevision',
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MyEventSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
MyEventSubscriber::newRevision public function Custom logic to determine new revision for a scheduled transition.