You are here

public function SampleDataProcessor::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

modules/sample_data/src/Plugin/YamlContent/SampleDataProcessor.php, line 36

Class

SampleDataProcessor
Import processor to support entity queries and references.

Namespace

Drupal\sample_data\Plugin\YamlContent

Code

public function preprocess(array &$import_data) {
  $config = $this->configuration;
  if (isset($config['dataset'])) {
    $data = $this
      ->loadSampleDataSet($config['dataset']);
    $value = $data
      ->get($config['lookup']);
  }
  elseif (isset($config['data_type'])) {
    $value = $this->dataLoader
      ->loadSample($config['data_type'], $config);
  }
  if ($value) {
    $import_data[] = $value;
  }
}