You are here

function lightning_scheduler_entity_presave in Lightning Workflow 8

Same name and namespace in other branches
  1. 8.3 modules/lightning_scheduler/lightning_scheduler.module \lightning_scheduler_entity_presave()
  2. 8.2 modules/lightning_scheduler/lightning_scheduler.module \lightning_scheduler_entity_presave()

Implements hook_entity_presave().

File

modules/lightning_scheduler/lightning_scheduler.module, line 92

Code

function lightning_scheduler_entity_presave(EntityInterface $entity) {
  if ($entity instanceof FieldableEntityInterface && $entity
    ->hasField('scheduled_publication') && $entity
    ->get('scheduled_publication')
    ->count()) {
    $entity->scheduled_moderation_state->value = $entity->moderation_state->value;
    if (isset($entity->original)) {
      $entity->moderation_state->value = $entity->original->moderation_state->value;
    }
  }
}