You are here

public function EntityDeleteAction::execute in Views Bulk Operations (VBO) 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/Action/EntityDeleteAction.php \Drupal\views_bulk_operations\Plugin\Action\EntityDeleteAction::execute()
  2. 8 src/Plugin/Action/EntityDeleteAction.php \Drupal\views_bulk_operations\Plugin\Action\EntityDeleteAction::execute()
  3. 8.2 src/Plugin/Action/EntityDeleteAction.php \Drupal\views_bulk_operations\Plugin\Action\EntityDeleteAction::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

src/Plugin/Action/EntityDeleteAction.php, line 24

Class

EntityDeleteAction
Delete entity action with default confirmation form.

Namespace

Drupal\views_bulk_operations\Plugin\Action

Code

public function execute($entity = NULL) {
  if ($entity instanceof TranslatableInterface && !$entity
    ->isDefaultTranslation()) {
    $untranslated_entity = $entity
      ->getUntranslated();
    $untranslated_entity
      ->removeTranslation($entity
      ->language()
      ->getId());
    $untranslated_entity
      ->save();
    return $this
      ->t('Delete translations');
  }
  else {
    $entity
      ->delete();
    return $this
      ->t('Delete entities');
  }
}