public function ProcessedContentLoader::postprocessData in YAML Content 8.2
Evaluate the current import data array and run any preprocessing needed.
Any data keys starting with '#' indicate preprocessing instructions that should be executed on the data prior to import. The data array is altered directly and fully prepared for import.
Parameters
array $import_data: The current content data being evaluated for import. This array is altered directly and returned without the processing key.
mixed $loaded_content: The loaded content object generated from the given import data.
array $context: Contextual data passed by reference to preprocessing plugins.
Throws
Exception
4 calls to ProcessedContentLoader::postprocessData()
- ProcessedContentLoader::importEntity in src/
ContentLoader/ ProcessedContentLoader.php - Load an entity from a loaded import data outline.
- ProcessedContentLoader::importEntityField in src/
ContentLoader/ ProcessedContentLoader.php - Process import data into an appropriate field value and assign it.
- ProcessedContentLoader::importFieldItem in src/
ContentLoader/ ProcessedContentLoader.php - Process import data for an individual field list item value.
- ProcessedContentLoader::loadContent in src/
ContentLoader/ ProcessedContentLoader.php - Load all demo content for a set of parsed data.
File
- src/
ContentLoader/ ProcessedContentLoader.php, line 256
Class
- ProcessedContentLoader
- A ContentLoader supporting processing of content through plugins.
Namespace
Drupal\yaml_content\ContentLoaderCode
public function postprocessData(array &$import_data, &$loaded_content, array &$context) {
// Abort if there are no postprocessing instructions.
if (!isset($import_data['#postprocess'])) {
return;
}
if (!is_array($import_data['#postprocess'])) {
throw new Exception('Postprocessing instructions must be provided as an array.');
}
// Execute all processing actions.
foreach ($import_data['#postprocess'] as $key => $data) {
// @todo Execute postprocess actions.
if (isset($data['#plugin'])) {
// Load the plugin.
$processor = $this
->loadProcessor($data['#plugin'], $context);
assert($processor instanceof ImportProcessorInterface, 'Postprocess plugin [' . $data['#plugin'] . '] failed to load a valid ImportProcessor plugin.');
// @todo Provide required context as defined by plugin definition.
// @todo Execute plugin on $loaded_content.
}
else {
throw new Exception('Postprocessing instructions require a defined "#plugin" identifier.');
}
}
}