diff --git a/src/Command/Shared/ExportTrait.php b/src/Command/Shared/ExportTrait.php index 534b18d2f..549ffe161 100644 --- a/src/Command/Shared/ExportTrait.php +++ b/src/Command/Shared/ExportTrait.php @@ -9,6 +9,7 @@ use Drupal\Component\Serialization\Yaml; use Drupal\Console\Core\Style\DrupalStyle; +use Symfony\Component\Console\Exception\InvalidOptionException; /** * Class ConfigExportTrait @@ -72,14 +73,18 @@ protected function exportConfig($directory, DrupalStyle $io, $message) } /** - * @param string $module + * @param string $moduleName * @param DrupalStyle $io */ - protected function exportConfigToModule($module, DrupalStyle $io, $message) + protected function exportConfigToModule($moduleName, DrupalStyle $io, $message) { $io->info($message); - $module = $this->extensionManager->getModule($module); + $module = $this->extensionManager->getModule($moduleName); + + if (empty($module)) { + throw new InvalidOptionException(sprintf('The module %s does not exist.', $moduleName)); + } foreach ($this->configExport as $fileName => $config) { $yamlConfig = Yaml::encode($config['data']);