Function for delete entity.

Paramètres

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 dans src/Form/SpambotUserspamForm.php
Processor for delete batch operations.

Fichier

src/Form/SpambotUserspamForm.php, line 683

Classe

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();
        }
    }
}