You are here

public function TemplateProcessor::preprocess in YAML Content 8.2

Pre-process import data and manipulate it prior to content creation.

Parameters

array $import_data: The data array being processed for content import.

Overrides ImportProcessorBase::preprocess

File

src/Plugin/YamlContent/TemplateProcessor.php, line 50

Class

TemplateProcessor
A content processor plugin supporting content templates in defined content.

Namespace

Drupal\yaml_content\Plugin\YamlContent

Code

public function preprocess(array &$import_data) {
  $template_data = $this
    ->loadTemplate();
  $count = $this
    ->getContextValue('count');

  // Populate the template the designated number of times.
  for ($i = 0; $i < $count; $i++) {

    // Add another iteration of the template.
    $import_data[] = $template_data;
  }
}