+
+ /**
+ * Assure that a config directory exists and is populated.
+ *
+ * @param CommandData $commandData
+ * @param $directory
+ * @throws \Exception
+ */
+ protected function validateConfigDir(CommandData $commandData, $directory)
+ {
+ if (!file_exists($directory)) {
+ throw new \Exception(dt('The config source directory @config does not exist.', ['@config' => $directory]));
+ }
+ if (!is_dir($directory)) {
+ throw new \Exception(dt('The config source @config is not a directory.', ['@config' => $directory]));
+ }
+ // Skip config import with a warning if specified config dir is empty.
+ if (!$this->hasConfigFiles($directory)) {
+ $this->logger()->warning(dt('Configuration import directory @config does not contain any configuration; will skip import.', ['@config' => $directory]));
+ $commandData->input()->setOption('config-dir', '');
+ }
+ }