You are here

protected function BaseUpdateRunner::removeUpdate in Scheduled Updates 8

Remove update from reference field value.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

\Drupal\scheduled_updates\ScheduledUpdateInterface $update:

$field_id:

1 call to BaseUpdateRunner::removeUpdate()
BaseUpdateRunner::prepareEntityForUpdate in src/Plugin/BaseUpdateRunner.php
Prepare an entity to be updated.

File

src/Plugin/BaseUpdateRunner.php, line 550
Contains \Drupal\scheduled_updates\Plugin\BaseUpdateRunner.

Class

BaseUpdateRunner

Namespace

Drupal\scheduled_updates\Plugin

Code

protected function removeUpdate(ContentEntityInterface $entity, ScheduledUpdateInterface $update, $field_id) {
  $current_update_ids = $this
    ->getEntityReferenceTargetIds($entity, $field_id);
  $new_update_ids = array_diff($current_update_ids, [
    $update
      ->id(),
  ]);
  $entity
    ->get($field_id)
    ->setValue($new_update_ids);
}