You are here

public function SpambotUserspamForm::deleteEntity in Spambot 8

Function for delete entity.

Parameters

int $id: Entity id.

string $type: Entity type.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to SpambotUserspamForm::deleteEntity()
SpambotUserspamForm::deleteEntitiesBatch in src/Form/SpambotUserspamForm.php
Processor for delete batch operations.

File

src/Form/SpambotUserspamForm.php, line 683

Class

SpambotUserspamForm
Settings form to save the configuration for Spambot.

Namespace

Drupal\spambot\Form

Code

public function deleteEntity($id, $type) {
  $storage = $this->entityTypeManager
    ->getStorage($type);
  $entity = $storage
    ->load($id);
  if (!empty($entity)) {
    $entity
      ->delete();

    // Delete from node_spambot table.
    if ($type === 'node') {
      $this->connection
        ->delete('node_spambot')
        ->condition('nid', $id)
        ->execute();
    }
  }
}