Ejemplo n.º 1
0
 /**
  * Loads a plugin config file and merges it to plugin config
  *
  * @param string       $magentoRootFolder
  * @param SplFileInfo $file
  */
 protected function registerPluginConfigFile($magentoRootFolder, $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, $magentoRootFolder, $file));
     $this->_pluginConfig = ArrayFunctions::mergeArrays($this->_pluginConfig, $localPluginConfig);
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * Loads a plugin config file and merges it to plugin config
  *
  * @param string       $magentoRootFolder
  * @param SplFileInfo $file
  */
 protected function registerPluginConfigFile($magentoRootFolder, $file)
 {
     if (String::startsWith($file->getPathname(), 'vfs://')) {
         $path = $file->getPathname();
     } else {
         $path = $file->getRealPath();
         if ($path === "") {
             throw new \UnexpectedValueException(sprintf("Realpath for '%s' did return an empty string.", $file));
         }
         if ($path === false) {
             $this->_output->writeln(sprintf("<error>Plugin config file broken link '%s'</error>", $file));
             return;
         }
     }
     if (OutputInterface::VERBOSITY_DEBUG <= $this->_output->getVerbosity()) {
         $this->_output->writeln('<debug>Load plugin config <comment>' . $path . '</comment></debug>');
     }
     $localPluginConfig = \file_get_contents($path);
     if ($localPluginConfig === false) {
         $this->_output->writeln(sprintf("<error>Failed to read from plugin config file '%s'</error>", $file));
     }
     $localPluginConfig = Yaml::parse($this->applyVariables($localPluginConfig, $magentoRootFolder, $file));
     $this->_pluginConfig = ArrayFunctions::mergeArrays($this->_pluginConfig, $localPluginConfig);
 }