/** * @param InputInterface $input * @param OutputInterface $output * @throws \InvalidArgumentException */ protected function createDatabase(InputInterface $input, OutputInterface $output) { $dbOptions = array('--dbHost', '--dbUser', '--dbPass', '--dbName'); $dbOptionsFound = 0; foreach ($dbOptions as $dbOption) { foreach ($this->getCliArguments() as $definedCliOption) { if (String::startsWith($definedCliOption, $dbOption)) { $dbOptionsFound++; } } } $hasAllOptions = $dbOptionsFound == 4; // if all database options were passed in at cmd line if ($hasAllOptions) { $this->config['db_host'] = $input->getOption('dbHost'); $this->config['db_user'] = $input->getOption('dbUser'); $this->config['db_pass'] = $input->getOption('dbPass'); $this->config['db_name'] = $input->getOption('dbName'); $this->config['db_port'] = $input->getOption('dbPort'); $db = $this->validateDatabaseSettings($output, $input); if ($db === false) { throw new \InvalidArgumentException("Database configuration is invalid", null); } } else { $dialog = $this->getHelperSet()->get('dialog'); do { $this->config['db_host'] = $dialog->askAndValidate($output, '<question>Please enter the database host:</question> <comment>[localhost]</comment>: ', $this->notEmptyCallback, false, 'localhost'); $this->config['db_user'] = $dialog->askAndValidate($output, '<question>Please enter the database username:</question> ', $this->notEmptyCallback); $this->config['db_pass'] = $dialog->ask($output, '<question>Please enter the database password:</question> '); $this->config['db_name'] = $dialog->askAndValidate($output, '<question>Please enter the database name:</question> ', $this->notEmptyCallback); $this->config['db_port'] = $dialog->askAndValidate($output, '<question>Please enter the database port:</question> <comment>[3306]</comment>: ', $this->notEmptyCallback, false, 3306); $db = $this->validateDatabaseSettings($output, $input); } while ($db === false); } $this->config['db'] = $db; }
/** * Loads a plugin config file and merges it to plugin config * * @param string $contaoRootFolder * @param SplFileInfo $file */ protected function registerPluginConfigFile($contaoRootFolder, $file) { if (String::startsWith($file->getPathname(), 'vfs://')) { $path = $file->getPathname(); } else { $path = $file->getRealPath(); } if (OutputInterface::VERBOSITY_DEBUG <= $this->_output->getVerbosity()) { $this->_output->writeln('<debug>Load plugin config <comment>' . $path . '</comment></debug>'); } $localPluginConfig = \file_get_contents($path); $localPluginConfig = Yaml::parse($this->applyVariables($localPluginConfig, $contaoRootFolder, $file)); $this->_pluginConfig = ArrayFunctions::mergeArrays($this->_pluginConfig, $localPluginConfig); }