You are here

public function TermDevelGenerate::generateElements in Devel 8

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

Business logic relating with each DevelGenerate plugin

Parameters

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

Overrides DevelGenerateBase::generateElements

File

devel_generate/src/Plugin/DevelGenerate/TermDevelGenerate.php, line 121

Class

TermDevelGenerate
Provides a TermDevelGenerate plugin.

Namespace

Drupal\devel_generate\Plugin\DevelGenerate

Code

public function generateElements(array $values) {
  if ($values['kill']) {
    $this
      ->deleteVocabularyTerms($values['vids']);
    $this
      ->setMessage($this
      ->t('Deleted existing terms.'));
  }
  $vocabs = $this->vocabularyStorage
    ->loadMultiple($values['vids']);
  $new_terms = $this
    ->generateTerms($values['num'], $vocabs, $values['title_length']);
  if (!empty($new_terms)) {
    $this
      ->setMessage($this
      ->t('Created the following new terms: @terms', array(
      '@terms' => implode(', ', $new_terms),
    )));
  }
}