Function apply selected action to content.

Paramètres

array|null $values: FormState values.

array|null $nids: Array of nodes id.

array|null $cids: Array of comments id.

1 call to SpambotUserspamForm::actionUserContent()
SpambotUserspamForm::actionSubmit dans src/Form/SpambotUserspamForm.php
Function provide functional for button "take action".

Fichier

src/Form/SpambotUserspamForm.php, line 565

Classe

SpambotUserspamForm
Settings form to save the configuration for Spambot.

Namespace

Drupal\spambot\Form

Code

public function actionUserContent($values, $nids, $cids) {
    if ($values['action_content'] === 'delete_content') {
        if ($nids) {
            static::defaultBatchBuilderSettings();
            $this->batchBuilder
                ->addOperation([
                $this,
                'deleteEntitiesBatch',
            ], [
                $nids,
                'node',
            ]);
            $this->batchBuilder
                ->setFinishCallback([
                $this,
                'finishedDeleteEntities',
            ]);
        }
        if ($cids) {
            static::defaultBatchBuilderSettings();
            $this->batchBuilder
                ->addOperation([
                $this,
                'deleteEntitiesBatch',
            ], [
                $cids,
                'comment',
            ]);
            $this->batchBuilder
                ->setFinishCallback([
                $this,
                'finishedDeleteEntities',
            ]);
        }
        if ($nids || $cids) {
            batch_set($this->batchBuilder
                ->toArray());
        }
    }
    else {
        // Unpublish nodes and content.
        if ($nids) {
            static::defaultBatchBuilderSettings();
            $this->batchBuilder
                ->addOperation([
                $this,
                'entitiesUnpublish',
            ], [
                $nids,
                'node',
            ]);
            $this->batchBuilder
                ->setFinishCallback([
                $this,
                'finishedUnpublishEntities',
            ]);
        }
        if ($cids) {
            static::defaultBatchBuilderSettings();
            $this->batchBuilder
                ->addOperation([
                $this,
                'entitiesUnpublish',
            ], [
                $cids,
                'comment',
            ]);
            $this->batchBuilder
                ->setFinishCallback([
                $this,
                'finishedUnpublishEntities',
            ]);
        }
        if ($nids || $cids) {
            batch_set($this->batchBuilder
                ->toArray());
        }
    }
}