public function DefaultContentCommands::contentExportReferences in Default Content for D8 2.0.x
Same name and namespace in other branches
- 8 src/Commands/DefaultContentCommands.php \Drupal\default_content\Commands\DefaultContentCommands::contentExportReferences()
Exports an entity and all its referenced entities.
@command default-content:export-references @option folder Folder to export to, entities are grouped by entity type into directories. @aliases dcer
Parameters
string $entity_type_id: The entity type to export.
int $entity_id: The ID of the entity to export.
File
- src/
Commands/ DefaultContentCommands.php, line 64
Class
- DefaultContentCommands
- Class DefaultContentCommands.
Namespace
Drupal\default_content\CommandsCode
public function contentExportReferences($entity_type_id, $entity_id = NULL, $options = [
'folder' => NULL,
]) {
$folder = $options['folder'];
if (is_null($entity_id)) {
$entities = \Drupal::entityQuery($entity_type_id)
->accessCheck(FALSE)
->execute();
}
else {
$entities = [
$entity_id,
];
}
// @todo Add paging.
foreach ($entities as $entity_id) {
$this->defaultContentExporter
->exportContentWithReferences($entity_type_id, $entity_id, $folder);
}
}