You are here

function scheduler_rules_integration_entity_insert in Scheduler 2.x

Implements hook_entity_insert().

File

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

Code

function scheduler_rules_integration_entity_insert(EntityInterface $entity) {

  // Invoke the Rules events to indicate that a new entity has been scheduled.
  $scheduler_manager = \Drupal::service('scheduler.manager');

  // If this entity type is is not supported by Scheduler then go further.
  if (!$scheduler_manager
    ->getPlugin($entity
    ->getEntityTypeId())) {
    return;
  }
  if (!empty($entity->publish_on->value)) {
    _scheduler_rules_integration_event($entity, 'NEW_FOR_PUBLISHING');
  }
  if (!empty($entity->unpublish_on->value)) {
    _scheduler_rules_integration_event($entity, 'NEW_FOR_UNPUBLISHING');
  }
}