protected function ExportCommand::execute in Tome 8
1 method overrides ExportCommand::execute()
- ExportContentCommand::execute in modules/
tome_sync/ src/ Commands/ ExportContentCommand.php
File
- modules/
tome_sync/ src/ Commands/ ExportCommand.php, line 90
Class
- ExportCommand
- Contains the tome:export command.
Namespace
Drupal\tome_sync\CommandsCode
protected function execute(InputInterface $input, OutputInterface $output) {
$options = $input
->getOptions();
if (!$options['yes'] && !$this
->io()
->confirm('The files in your export directory will be deleted and replaced.', FALSE)) {
return 0;
}
if (!$this
->runCommand($this->executable . " config:export -y", NULL, NULL)) {
return 1;
}
if (!$this->exporter
->deleteExportDirectories()) {
$this
->io()
->error('Unable to delete existing export directories, please delete manually.');
return 1;
}
$entities = $this->exporter
->getContentToExport();
$id_pairs = [];
$commands = [];
foreach ($entities as $entity_type_id => $ids) {
foreach ($ids as $id) {
$id_pairs[] = "{$entity_type_id}:{$id}";
}
}
foreach (array_chunk($id_pairs, $options['entity-count']) as $chunk) {
$commands[] = $this->executable . ' tome:export-content ' . escapeshellarg(implode(',', $chunk));
}
$collected_errors = $this
->runCommands($commands, $options['process-count'], 0);
if (!empty($collected_errors)) {
$this
->io()
->error('Errors encountered when exporting content:');
$this
->displayErrors($collected_errors);
return 1;
}
$this->eventDispatcher
->dispatch(TomeSyncEvents::EXPORT_ALL, new Event());
$this
->io()
->success('Exported config, content, and files.');
}