You are here

public function DeleteAllTranslationsAction::executeMultiple in Lingotek Translation 3.7.x

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

Executes the plugin for an array of objects.

Parameters

array $objects: An array of entities.

Overrides ActionBase::executeMultiple

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

File

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

Class

DeleteAllTranslationsAction
Assigns ownership of a node to a user.

Namespace

Drupal\lingotek\Plugin\Action

Code

public function executeMultiple(array $entities) {
  $entityInfo = [];
  $languages = \Drupal::languageManager()
    ->getLanguages();
  foreach ($entities as $entity) {
    $source_language = $entity
      ->getUntranslated()
      ->language();
    foreach ($languages as $langcode => $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.");
  }
}