You are here

protected function ContentDevelGenerate::contentKill in Devel 8.3

Same name and namespace in other branches
  1. 8 devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::contentKill()
  2. 8.2 devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::contentKill()
  3. 4.x devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate::contentKill()

Deletes all nodes of given node types.

Parameters

array $values: The input values from the settings form.

2 calls to ContentDevelGenerate::contentKill()
ContentDevelGenerate::batchContentKill in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php
Batch wrapper for calling ContentKill.
ContentDevelGenerate::generateContent in devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php
Generate content when not in batch mode.

File

devel_generate/src/Plugin/DevelGenerate/ContentDevelGenerate.php, line 583

Class

ContentDevelGenerate
Provides a ContentDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

protected function contentKill(array $values) {
  $nids = $this->nodeStorage
    ->getQuery()
    ->condition('type', $values['node_types'], 'IN')
    ->execute();
  if (!empty($nids)) {
    $nodes = $this->nodeStorage
      ->loadMultiple($nids);
    $this->nodeStorage
      ->delete($nodes);
    $this
      ->setMessage($this
      ->t('Deleted %count nodes.', [
      '%count' => count($nids),
    ]));
  }
}