public function ContentLoaderBase::loadContent in YAML Content 8.2
Load all demo content for a set of parsed data.
Parameters
array $content_data: The parsed content structure to be imported.
Return value
array An array of loaded entities from the content data.
Overrides ContentLoaderInterface::loadContent
See also
\Drupal\yaml_content\ContentLoader\ContentLoaderInterface::parseContent()
2 calls to ContentLoaderBase::loadContent()
- ContentLoaderBase::loadContentBatch in src/
ContentLoader/ ContentLoaderBase.php - Load a batch of content files.
- ProcessedContentLoader::loadContent in src/
ContentLoader/ ProcessedContentLoader.php - Load all demo content for a set of parsed data.
1 method overrides ContentLoaderBase::loadContent()
- ProcessedContentLoader::loadContent in src/
ContentLoader/ ProcessedContentLoader.php - Load all demo content for a set of parsed data.
File
- src/
ContentLoader/ ContentLoaderBase.php, line 145
Class
- ContentLoaderBase
- A base ContentLoader implementation to be extended by new content loaders.
Namespace
Drupal\yaml_content\ContentLoaderCode
public function loadContent(array $content_data) {
// Create each entity defined in the yaml content.
$loaded_content = [];
foreach ($content_data as $content_item) {
$entity = $this
->importEntity($content_item);
// Dispatch the pre-save event.
$entity_pre_save_event = new EntityPreSaveEvent($this, $entity, $content_item);
$this->dispatcher
->dispatch(YamlContentEvents::ENTITY_PRE_SAVE, $entity_pre_save_event);
// Save the entity.
$entity
->save();
// Dispatch the post-save event.
$entity_post_save_event = new EntityPostSaveEvent($this, $entity, $content_item);
$this->dispatcher
->dispatch(YamlContentEvents::ENTITY_POST_SAVE, $entity_post_save_event);
$loaded_content[] = $entity;
}
return $loaded_content;
}