class SchedulerEventSubscriber in Scheduler content moderation integration 8
Handle scheduler events.
The six possible Scheduler events are: SchedulerEvents::PRE_PUBLISH SchedulerEvents::PUBLISH SchedulerEvents::PRE_UNPUBLISH SchedulerEvents::UNPUBLISH SchedulerEvents::PRE_PUBLISH_IMMEDIATELY SchedulerEvents::PUBLISH_IMMEDIATELY.
Hierarchy
- class \Drupal\scheduler_content_moderation_integration\EventSubscriber\SchedulerEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of SchedulerEventSubscriber
1 string reference to 'SchedulerEventSubscriber'
1 service uses SchedulerEventSubscriber
File
- src/
EventSubscriber/ SchedulerEventSubscriber.php, line 20
Namespace
Drupal\scheduler_content_moderation_integration\EventSubscriberView source
class SchedulerEventSubscriber implements EventSubscriberInterface {
/**
* Operations to perform after Scheduler publishes a node immediately.
*
* This is during the edit process, not via cron.
*
* @param \Drupal\scheduler\SchedulerEvent $event
* The event being acted on.
*/
public function publishImmediately(SchedulerEvent $event) {
/** @var \Drupal\node\Entity\Node $node */
$node = $event
->getNode();
$node
->set('moderation_state', $node->publish_state
->getValue());
$event
->setNode($node);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// The values in the arrays give the function names above.
$events[SchedulerEvents::PUBLISH_IMMEDIATELY][] = [
'publishImmediately',
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SchedulerEventSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
SchedulerEventSubscriber:: |
public | function | Operations to perform after Scheduler publishes a node immediately. |