public function DefaultContentDeployCommands::contentDeployExport in Default Content Deploy 8
Exports a single entity or group of entities.
@command default-content-deploy:export
@option entity_id The ID of the entity to export. @option bundle Write out the exported bundle of entity @option skip_entities The ID of the entity to skip. @option force-update Deletes configurations files that are not used on the site. @option folder Path to the export folder. @usage drush dcde node Export all nodes @usage drush dcde node --folder='../content' Export all nodes from the specified folder. @usage drush dcde node --bundle=page Export all nodes with bundle page @usage drush dcde node --bundle=page,article --entity_id=2,3,4 Export all nodes with bundle page or article plus nodes with entities id 2, 3 and 4. @usage drush dcde node --bundle=page,article --skip_entities=5,7 Export all nodes with bundle page or article and skip nodes with entity id 5 and 7. @usage drush dcde node --skip_entities=5,7 Export all nodes and skip nodes with entity id 5 and 7. @aliases dcde,default-content-deploy-export
Parameters
$entity_type: The entity type to export. If a wrong content entity type is entered, module displays a list of all content entity types.
array $options: An associative array of options whose values come from cli, aliases, config, etc.
Throws
\Exception
File
- src/
Commands/ DefaultContentDeployCommands.php, line 91
Class
- DefaultContentDeployCommands
- Class DefaultContentDeployCommands.
Namespace
Drupal\default_content_deploy\CommandsCode
public function contentDeployExport($entity_type, array $options = [
'entity_id' => NULL,
'bundle' => NULL,
'skip_entities' => NULL,
'force-update' => FALSE,
'folder' => self::OPT,
]) {
try {
$entity_ids = $this
->processingArrayOption($options['entity_id']);
$skip_ids = $this
->processingArrayOption($options['skip_entities']);
$this->exporter
->setEntityTypeId($entity_type);
$this->exporter
->setEntityBundle($options['bundle']);
if (!empty($options['folder'])) {
$this->exporter
->setFolder($options['folder']);
}
$this->exporter
->setMode('default');
$this->exporter
->setForceUpdate($options['force-update']);
if ($entity_ids) {
$this->exporter
->setEntityIds($entity_ids);
}
if ($skip_ids) {
$this->exporter
->setSkipEntityIds($skip_ids);
}
$result = $this->exporter
->export()
->getResult();
$this
->displayExportResult($result);
} catch (\InvalidArgumentException $e) {
$content_entity_list = $this
->getAvailableEntityTypes();
$this->logger
->error($e
->getMessage());
$this->logger
->notice(dt('List of available content entity types:@types', [
'@types' => PHP_EOL . $content_entity_list,
]));
}
}