diff -u b/console/translations/en/default.content.export.taxonomy.yml b/console/translations/en/default.content.export.taxonomy.yml --- b/console/translations/en/default.content.export.taxonomy.yml +++ b/console/translations/en/default.content.export.taxonomy.yml @@ -1,12 +1,12 @@ -description: 'Exports a taxonomy term entities for a specific Taxonomy' +description: 'Exports all taxonomy terms entities for a specific Taxonomy' arguments: taxonomy-vid: 'The taxonony VID.' entity-id: 'The ID of the entity to export.' options: module: 'The Module to export taxonony terms' messages: - taxonomy-exported: 'Taxonomy %s was exported at module %s' - module-not-found: 'Module to export was not provided' + taxonomy-exported: 'Taxonomy %s was exported to module %s' + module-not-found: 'Module to export to was not provided' invalid-taxonomy: 'Taxonomy %s is invalid' questions: taxonomy: 'Taxonomy' diff -u b/src/Command/DefaultExportCommand.php b/src/Command/DefaultExportCommand.php --- b/src/Command/DefaultExportCommand.php +++ b/src/Command/DefaultExportCommand.php @@ -1,5 +1,9 @@ getArgument('entity-id'); $module = $input->getOption('module'); - if(!$module) { + if (!$module) { $io->warning($this->trans('commands.default.content.export.messages.module-not-found')); return; } @@ -70,11 +74,11 @@ $entityStorage = $entityManager->getStorage($entityType); $entity = $entityStorage->load($entityId); - if($entity) { + if ($entity) { $export = $defaultContentManger->exportContent($entityType, $entityId); $entityFileName = $this->getStringHelper()->createMachineName($entity->getName()) . '.json'; - $entityExportFile = $this->getSite()->getModulePath($module) . '/content/' . $entityType . '/' . $entityFileName; + $entityExportFile = $this->getSite()->getModulePath($module) . '/content/' . $entityType . '/' . $entityFileName; $fileSystem->dumpFile($entityExportFile, $export); @@ -87,7 +91,8 @@ ) ); - } else { + } + else { $io->warning( sprintf( $this->trans('commands.default.content.export.messages.entity-not-found'), @@ -101,11 +106,11 @@ /** * {@inheritdoc} */ - protected function interact(InputInterface $input, OutputInterface $output) - { + protected function interact(InputInterface $input, OutputInterface $output) { + $io = new DrupalStyle($input, $output); - // --module option + // --module option. $module = $input->getOption('module'); if (!$module) { // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion @@ -114,7 +119,7 @@ $input->setOption('module', $module); $entityManager = $this->getDrupalService('entity.manager'); - $entitytypes = $entityManager->getEntityTypeLabels(true); + $entitytypes = $entityManager->getEntityTypeLabels(TRUE); $entityType = $input->getArgument('entity-type'); if (!$entityType) { diff -u b/src/Command/DefaultExportTaxonomyCommand.php b/src/Command/DefaultExportTaxonomyCommand.php --- b/src/Command/DefaultExportTaxonomyCommand.php +++ b/src/Command/DefaultExportTaxonomyCommand.php @@ -60,19 +60,19 @@ return; } - $taxonomyManager = $this->getDrupalService('entity.manager')->getStorage('taxonomy_vocabulary'); - $taxononyTermManager = $this->getDrupalService('entity.manager')->getStorage('taxonomy_term'); + $vocabularyStorage = $this->getDrupalService('entity.manager')->getStorage('taxonomy_vocabulary'); + $termStorage = $this->getDrupalService('entity.manager')->getStorage('taxonomy_term'); - $taxonomyEntity = $taxonomyManager->load($taxonomyVid); + $vocabulary = $vocabularyStorage->load($taxonomyVid); - if($taxonomyEntity) { + if($vocabulary) { $query = \Drupal::entityQuery('taxonomy_term'); - $query->condition('vid', "$taxonomyVid"); + $query->condition('vid', $taxonomyVid); $terms = $query->execute(); foreach($terms as $term) { - $termEntity = $taxononyTermManager->load($term); + $termEntity = $termStorage->load($term); $export = $defaultContentManger->exportContent('taxonomy_term', $term); $entityFileName = $this->getStringHelper()->createMachineName($termEntity->getName()) . '.json'; $entityExportFile = $this->getSite()->getModulePath($module) . '/content/taxonomy_term/' . $entityFileName;