public function DefaultContentCommands::contentExport in Default Content for D8 8
Same name and namespace in other branches
- 2.0.x src/Commands/DefaultContentCommands.php \Drupal\default_content\Commands\DefaultContentCommands::contentExport()
Exports a single entity.
@command default-content:export @option file Write out the exported content to a file instead of stdout. @aliases dce
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 44
Class
- DefaultContentCommands
- Class DefaultContentCommands.
Namespace
Drupal\default_content\CommandsCode
public function contentExport($entity_type_id, $entity_id, $options = [
'file' => NULL,
]) {
$export = $this->defaultContentExporter
->exportContent($entity_type_id, $entity_id);
if ($file = $options['file']) {
file_put_contents($file, $export);
}
else {
$this
->output()
->write($export);
}
}