You are here

public function DeleteTranslationLingotekAction::executeMultiple in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  2. 4.0.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  3. 3.0.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  4. 3.1.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  5. 3.2.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  6. 3.3.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  7. 3.5.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  8. 3.6.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  9. 3.7.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()
  10. 3.8.x src/Plugin/Action/DeleteTranslationLingotekAction.php \Drupal\lingotek\Plugin\Action\DeleteTranslationLingotekAction::executeMultiple()

Executes the plugin for an array of objects.

Parameters

array $objects: An array of entities.

Overrides ActionBase::executeMultiple

1 call to DeleteTranslationLingotekAction::executeMultiple()
DeleteTranslationLingotekAction::execute in src/Plugin/Action/DeleteTranslationLingotekAction.php
Executes the plugin.

File

src/Plugin/Action/DeleteTranslationLingotekAction.php, line 20

Class

DeleteTranslationLingotekAction
Delete Lingotek translation of a content entity for one language.

Namespace

Drupal\lingotek\Plugin\Action

Code

public function executeMultiple(array $entities) {
  $entityInfo = [];
  $configuration = $this
    ->getConfiguration();
  $langcode = $configuration['language'];
  foreach ($entities as $entity) {
    $source_language = $entity
      ->getUntranslated()
      ->language();
    if ($source_language
      ->getId() !== $langcode && $entity
      ->hasTranslation($langcode)) {

      /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
      $entityInfo[$entity
        ->id()][$langcode] = $langcode;
    }
  }
  \Drupal::getContainer()
    ->get('tempstore.private')
    ->get('entity_delete_multiple_confirm')
    ->set(\Drupal::currentUser()
    ->id() . ':node', $entityInfo);
  if (empty($entityInfo)) {
    $this
      ->messenger()
      ->addWarning("No valid translations for deletion.");
  }
}