function scheduler_rules_integration_node_insert in Scheduler 8
Implements hook_ENTITY_TYPE_insert() for node entities.
File
- scheduler_rules_integration/
scheduler_rules_integration.module, line 24 - Scheduler Rules Integration.
Code
function scheduler_rules_integration_node_insert(EntityInterface $node) {
// Invoke the Rules events to indicate that a new node has been scheduled.
$scheduler_manager = \Drupal::service('scheduler.manager');
if (!empty($node->publish_on->value)) {
// @todo In 7.x we had the dates as parameters. These are available in Rules via node.publish_on.value so maybe we do not need the parms?
$event = new NewNodeIsScheduledForPublishingEvent($node);
$scheduler_manager
->dispatch($event, NewNodeIsScheduledForPublishingEvent::EVENT_NAME);
}
if (!empty($node->unpublish_on->value)) {
$event = new NewNodeIsScheduledForUnpublishingEvent($node);
$scheduler_manager
->dispatch($event, NewNodeIsScheduledForUnpublishingEvent::EVENT_NAME);
}
}