public function SpambotUserspamForm::actionUserContent in Spambot 8
Function apply selected action to content.
Parameters
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 in src/
Form/ SpambotUserspamForm.php - Function provide functional for button "take action".
File
- src/
Form/ SpambotUserspamForm.php, line 565
Class
- SpambotUserspamForm
- Settings form to save the configuration for Spambot.
Namespace
Drupal\spambot\FormCode
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());
}
}
}