Loading src/DeleteEntity.php +14 −4 Original line number Diff line number Diff line Loading @@ -2,15 +2,19 @@ namespace Drupal\entity_delete; use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Service for Deleting the entity. */ class DeleteEntity { use StringTranslationTrait; /** * Function to delete all the entities. * * @param int $delete_ids * @param array $delete_ids * Entity ids to be deleted. * @param int $count * Current row in the batch process. Loading @@ -23,8 +27,11 @@ class DeleteEntity { * @param string $context * Context. */ public static function deleteEntity($delete_ids, $count, $total_count, $entity, $bundle, &$context) { $context['message'] = t("Now processing :current_row of :highest_row", [':current_row' => $count, ":highest_row" => $total_count]); public static function deleteEntities(array $delete_ids, $count, $total_count, $entity, $bundle, &$context) { $context['message'] = t("Now processing :current_row of :highest_row", [ ':current_row' => $count, ":highest_row" => $total_count, ]); $storage_handler = \Drupal::entityTypeManager()->getStorage($entity); $entities = $storage_handler->loadMultiple($delete_ids); $storage_handler->delete($entities); Loading @@ -46,7 +53,10 @@ class DeleteEntity { public static function deleteEntityFinishedCallback($success, $results, $operations) { if ($success) { if ($results['bundle'] == 'all') { $message = t('Successfully deleted @num @entity(s).', ['@num' => $results['count'], '@entity' => $results['entity']]); $message = t('Successfully deleted @num @entity(s).', [ '@num' => $results['count'], '@entity' => $results['entity'], ]); } else { $message = t('Successfully deleted @num @entity(s) with @bundle.', [ Loading src/Form/EntityDeleteConfirmationForm.php +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; /** * Class EntityDeleteConfirmationForm. * The EntityDeleteConfirmationForm class. * * @package Drupal\entity_delete\Form */ Loading Loading @@ -159,7 +159,7 @@ class EntityDeleteConfirmationForm extends FormBase { foreach ($batch_ids as $delete_ids) { $count_ids += count($delete_ids); $batch['operations'][] = [ '\Drupal\entity_delete\DeleteEntity::deleteEntity', '\Drupal\entity_delete\DeleteEntity::deleteEntities', [ $delete_ids, $count_ids, Loading src/Form/EntityDeleteForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class EntityDeleteForm. * The EntityDeleteForm class. * * @package Drupal\entity_delete\Form */ Loading Loading @@ -102,13 +102,13 @@ class EntityDeleteForm extends FormBase { // properties of what the entity to delete. $form['displays']['show'] = [ '#type' => 'fieldset', '#title' => t('Entity Delete Settings'), '#title' => $this->t('Entity Delete Settings'), '#tree' => TRUE, '#attributes' => ['class' => ['container-inline']], ]; $content_entity_types = []; $entity_type_definations = $this->entityTypeManager->getDefinitions(); /* @var $definition \Drupal\Core\Entity\EntityTypeInterface */ /** @var \Drupal\Core\Entity\EntityTypeInterface $definition */ foreach ($entity_type_definations as $definition) { if ($definition instanceof ContentEntityType) { $content_entity_types[$definition->id()] = $definition->getLabel(); Loading Loading
src/DeleteEntity.php +14 −4 Original line number Diff line number Diff line Loading @@ -2,15 +2,19 @@ namespace Drupal\entity_delete; use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Service for Deleting the entity. */ class DeleteEntity { use StringTranslationTrait; /** * Function to delete all the entities. * * @param int $delete_ids * @param array $delete_ids * Entity ids to be deleted. * @param int $count * Current row in the batch process. Loading @@ -23,8 +27,11 @@ class DeleteEntity { * @param string $context * Context. */ public static function deleteEntity($delete_ids, $count, $total_count, $entity, $bundle, &$context) { $context['message'] = t("Now processing :current_row of :highest_row", [':current_row' => $count, ":highest_row" => $total_count]); public static function deleteEntities(array $delete_ids, $count, $total_count, $entity, $bundle, &$context) { $context['message'] = t("Now processing :current_row of :highest_row", [ ':current_row' => $count, ":highest_row" => $total_count, ]); $storage_handler = \Drupal::entityTypeManager()->getStorage($entity); $entities = $storage_handler->loadMultiple($delete_ids); $storage_handler->delete($entities); Loading @@ -46,7 +53,10 @@ class DeleteEntity { public static function deleteEntityFinishedCallback($success, $results, $operations) { if ($success) { if ($results['bundle'] == 'all') { $message = t('Successfully deleted @num @entity(s).', ['@num' => $results['count'], '@entity' => $results['entity']]); $message = t('Successfully deleted @num @entity(s).', [ '@num' => $results['count'], '@entity' => $results['entity'], ]); } else { $message = t('Successfully deleted @num @entity(s) with @bundle.', [ Loading
src/Form/EntityDeleteConfirmationForm.php +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; /** * Class EntityDeleteConfirmationForm. * The EntityDeleteConfirmationForm class. * * @package Drupal\entity_delete\Form */ Loading Loading @@ -159,7 +159,7 @@ class EntityDeleteConfirmationForm extends FormBase { foreach ($batch_ids as $delete_ids) { $count_ids += count($delete_ids); $batch['operations'][] = [ '\Drupal\entity_delete\DeleteEntity::deleteEntity', '\Drupal\entity_delete\DeleteEntity::deleteEntities', [ $delete_ids, $count_ids, Loading
src/Form/EntityDeleteForm.php +3 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class EntityDeleteForm. * The EntityDeleteForm class. * * @package Drupal\entity_delete\Form */ Loading Loading @@ -102,13 +102,13 @@ class EntityDeleteForm extends FormBase { // properties of what the entity to delete. $form['displays']['show'] = [ '#type' => 'fieldset', '#title' => t('Entity Delete Settings'), '#title' => $this->t('Entity Delete Settings'), '#tree' => TRUE, '#attributes' => ['class' => ['container-inline']], ]; $content_entity_types = []; $entity_type_definations = $this->entityTypeManager->getDefinitions(); /* @var $definition \Drupal\Core\Entity\EntityTypeInterface */ /** @var \Drupal\Core\Entity\EntityTypeInterface $definition */ foreach ($entity_type_definations as $definition) { if ($definition instanceof ContentEntityType) { $content_entity_types[$definition->id()] = $definition->getLabel(); Loading