X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FConfig%2FExportSingleCommand.php;h=71798888462079947a6c05290340aa018eea5749;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=4e632eee8630ce3039f06f48c377e3af40d8f2ed;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Config/ExportSingleCommand.php b/vendor/drupal/console/src/Command/Config/ExportSingleCommand.php index 4e632eee8..717988884 100644 --- a/vendor/drupal/console/src/Command/Config/ExportSingleCommand.php +++ b/vendor/drupal/console/src/Command/Config/ExportSingleCommand.php @@ -12,17 +12,19 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Utils\Validator; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Config\CachedStorage; -use Drupal\Console\Core\Style\DrupalStyle; -use Drupal\Console\Core\Command\Shared\CommandTrait; use Drupal\Console\Command\Shared\ExportTrait; +use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Extension\Manager; +use Drupal\Core\Language\LanguageManagerInterface; +use Webmozart\PathUtil\Path; class ExportSingleCommand extends Command { - use CommandTrait; + use ModuleTrait; use ExportTrait; /** @@ -40,23 +42,47 @@ class ExportSingleCommand extends Command */ protected $configStorage; + /** + * @var Manager + */ + protected $extensionManager; + + /** + * @var Configuration. + */ protected $configExport; + /** + * @var LanguageManagerInterface + */ + protected $languageManager; + + /** + * @var Validator + */ + protected $validator; + /** * ExportSingleCommand constructor. * * @param EntityTypeManagerInterface $entityTypeManager * @param CachedStorage $configStorage * @param Manager $extensionManager + * @param languageManager $languageManager + * @param Validator $validator */ public function __construct( EntityTypeManagerInterface $entityTypeManager, CachedStorage $configStorage, - Manager $extensionManager + Manager $extensionManager, + LanguageManagerInterface $languageManager, + Validator $validator ) { $this->entityTypeManager = $entityTypeManager; $this->configStorage = $configStorage; $this->extensionManager = $extensionManager; + $this->languageManager = $languageManager; + $this->validator = $validator; parent::__construct(); } @@ -103,7 +129,8 @@ class ExportSingleCommand extends Command null, InputOption::VALUE_NONE, $this->trans('commands.config.export.single.options.remove-config-hash') - ); + ) + ->setAliases(['ces']); } /* @@ -124,8 +151,8 @@ class ExportSingleCommand extends Command uasort($entity_types, 'strnatcasecmp'); $config_types = [ - 'system.simple' => $this->trans('commands.config.export.single.options.simple-configuration'), - ] + $entity_types; + 'system.simple' => $this->trans('commands.config.export.single.options.simple-configuration'), + ] + $entity_types; return $config_types; } @@ -174,20 +201,18 @@ class ExportSingleCommand extends Command */ protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $config_types = $this->getConfigTypes(); $name = $input->getOption('name'); if (!$name) { - $type = $io->choiceNoList( + $type = $this->getIo()->choiceNoList( $this->trans('commands.config.export.single.questions.config-type'), array_keys($config_types), 'system.simple' ); $names = $this->getConfigNames($type); - $name = $io->choiceNoList( + $name = $this->getIo()->choiceNoList( $this->trans('commands.config.export.single.questions.name'), array_keys($names) ); @@ -196,14 +221,16 @@ class ExportSingleCommand extends Command $definition = $this->entityTypeManager->getDefinition($type); $name = $definition->getConfigPrefix() . '.' . $name; } - $input->setOption('name', $name); + + $input->setOption('name', [$name]); } - $module = $input->getOption('module'); + // --module option + $module = $this->getModuleOption(); if ($module) { $optionalConfig = $input->getOption('optional'); if (!$optionalConfig) { - $optionalConfig = $io->confirm( + $optionalConfig = $this->getIo()->confirm( $this->trans('commands.config.export.single.questions.optional'), true ); @@ -212,14 +239,14 @@ class ExportSingleCommand extends Command } if (!$input->getOption('remove-uuid')) { - $removeUuid = $io->confirm( + $removeUuid = $this->getIo()->confirm( $this->trans('commands.config.export.single.questions.remove-uuid'), true ); $input->setOption('remove-uuid', $removeUuid); } if (!$input->getOption('remove-config-hash')) { - $removeHash = $io->confirm( + $removeHash = $this->getIo()->confirm( $this->trans('commands.config.export.single.questions.remove-config-hash'), true ); @@ -227,67 +254,93 @@ class ExportSingleCommand extends Command } } - /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $directory = $input->getOption('directory'); $module = $input->getOption('module'); - $ame = $input->getOption('name'); + $name = $input->getOption('name'); $optional = $input->getOption('optional'); $removeUuid = $input->getOption('remove-uuid'); $removeHash = $input->getOption('remove-config-hash'); + $includeDependencies = $input->getOption('include-dependencies'); + + foreach ($this->getLanguage() as $value) { + foreach ($name as $nameItem) { + $config = $this->getConfiguration( + $nameItem, + $removeUuid, + $removeHash, + $value + ); - foreach ($ame as $nameItem) { - $config = $this->getConfiguration( - $nameItem, - $removeUuid, - $removeHash - ); - - if ($config) { - $this->configExport[$nameItem] = [ - 'data' => $config, - 'optional' => $optional - ]; - - if ($input->getOption('include-dependencies')) { - // Include config dependencies in export files - if ($dependencies = $this->fetchDependencies($config, 'config')) { - $this->resolveDependencies($dependencies, $optional); + if ($config) { + $this->configExport[$nameItem] = [ + 'data' => $config, + 'optional' => $optional + ]; + + if ($includeDependencies) { + // Include config dependencies in export files + if ($dependencies = $this->fetchDependencies($config, 'config')) { + $this->resolveDependencies($dependencies, $optional); + } } + } else { + $this->getIo()->error($this->trans('commands.config.export.single.messages.config-not-found')); } - } else { - $io->error($this->trans('commands.config.export.single.messages.config-not-found')); } - } - if ($module) { - $this->exportConfigToModule( - $module, - $io, - $this->trans( - 'commands.config.export.single.messages.config-exported' - ) - ); + if ($module) { + $this->exportConfigToModule( + $module, + $this->trans( + 'commands.config.export.single.messages.config-exported' + ) + ); - return 0; - } + return 0; + } - if (!$directory) { - $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); - } + if (!is_dir($directory)) { + $directory = $directory_copy = config_get_config_directory(CONFIG_SYNC_DIRECTORY); + if ($value) { + $directory = $directory_copy .'/' . str_replace('.', '/', $value); + } + } else { + $directory = $directory_copy .'/' . str_replace('.', '/', $value); + $directory = Path::canonicalize($directory); + if (!file_exists($directory)) { + mkdir($directory, 0755, true); + } + } - $this->exportConfig( - $directory, - $io, - $this->trans('commands.config.export.single.messages.config-exported') - ); + $this->exportConfig( + $directory, + $this->trans('commands.config.export.single.messages.config-exported') + ); + } return 0; } + + /** + * Get the languague enable. + */ + protected function getLanguage() + { + $output = []; + // Get the language that be for default. + $default_id = $this->languageManager->getDefaultLanguage()->getId(); + foreach ($this->languageManager->getLanguages() as $key => $value) { + if ($default_id == $key) { + $output[] = ''; + } else { + $output[] = 'language.' . $value->getId(); + } + } + return $output; + } }