public function Exporter::exportModuleContent in Default Content for D8 8
Same name and namespace in other branches
- 2.0.x src/Exporter.php \Drupal\default_content\Exporter::exportModuleContent()
Exports all of the content defined in a module's info file.
Parameters
string $module_name: The name of the module.
Return value
string[][] The serialized entities keyed by entity type and UUID.
Throws
\InvalidArgumentException If any UUID is not found.
Overrides ExporterInterface::exportModuleContent
File
- src/
Exporter.php, line 205
Class
- Exporter
- A service for handling import of default content.
Namespace
Drupal\default_contentCode
public function exportModuleContent($module_name) {
$info_file = $this->moduleHandler
->getModule($module_name)
->getPathname();
$info = $this->infoParser
->parse($info_file);
$exported_content = [];
if (empty($info['default_content'])) {
return $exported_content;
}
foreach ($info['default_content'] as $entity_type => $uuids) {
foreach ($uuids as $uuid) {
$entity = $this->entityRepository
->loadEntityByUuid($entity_type, $uuid);
if (!$entity) {
throw new \InvalidArgumentException(sprintf('Entity "%s" with UUID "%s" does not exist', $entity_type, $uuid));
}
$exported_content[$entity_type][$uuid] = $this
->exportContent($entity_type, $entity
->id());
}
}
return $exported_content;
}