You are here

function scheduler_rules_integration_node_update in Scheduler 8

Implements hook_ENTITY_TYPE_update() for node entities.

File

scheduler_rules_integration/scheduler_rules_integration.module, line 41
Scheduler Rules Integration.

Code

function scheduler_rules_integration_node_update(EntityInterface $node) {

  // Invoke Rules events to indicate that an existing node has been scheduled.
  $scheduler_manager = \Drupal::service('scheduler.manager');
  if (!empty($node->publish_on->value)) {
    $event = new ExistingNodeIsScheduledForPublishingEvent($node, [
      'node' => $node,
    ]);
    $scheduler_manager
      ->dispatch($event, ExistingNodeIsScheduledForPublishingEvent::EVENT_NAME);
  }
  if (!empty($node->unpublish_on->value)) {
    $event = new ExistingNodeIsScheduledForUnpublishingEvent($node);
    $scheduler_manager
      ->dispatch($event, ExistingNodeIsScheduledForUnpublishingEvent::EVENT_NAME);
  }
}