You are here

protected function EmbeddedUpdateRunner::reactivateUpdates in Scheduled Updates 8

Reactive any updates that are on this entity that have been deactived previously.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

See also

::deactivateUpdates()

1 call to EmbeddedUpdateRunner::reactivateUpdates()
EmbeddedUpdateRunner::onEntityUpdate in src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php
Fires when entity of type to be updated is changed.

File

src/Plugin/UpdateRunner/EmbeddedUpdateRunner.php, line 130
Contains \Drupal\scheduled_updates\Plugin\UpdateRunner\EmbeddedUpdateRunner.

Class

EmbeddedUpdateRunner
The default Embedded Update Runner.

Namespace

Drupal\scheduled_updates\Plugin\UpdateRunner

Code

protected function reactivateUpdates(ContentEntityInterface $entity) {
  if ($update_ids = $this
    ->getUpdateIdsOnEntity($entity)) {
    $storage = $this->entityTypeManager
      ->getStorage('scheduled_update');
    $query = $storage
      ->getQuery();
    $query
      ->condition('status', [
      ScheduledUpdateInterface::STATUS_UNRUN,
      ScheduledUpdateInterface::STATUS_REQUEUED,
    ], 'NOT IN');
    $query
      ->condition($this->entityTypeManager
      ->getDefinition('scheduled_update')
      ->getKey('id'), $update_ids, 'IN');
    $non_active_update_ids = $query
      ->execute();
    $non_active_updates = $storage
      ->loadMultiple($non_active_update_ids);
    foreach ($non_active_updates as $non_active_update) {
      $non_active_update->status = ScheduledUpdateInterface::STATUS_UNRUN;
    }
  }
}