Back to SetConfigurationCommand class

Method doExecute

protected int
doExecute
(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output)
Internal function to execute the command.
Parameters
  • \Symfony\Component\Console\Input\InputInterface $input The input to inject into the command.
  • \Symfony\Component\Console\Output\OutputInterface $output The output to inject into the command.
Returns
  • int The command exit code
Since
  • 4.0.0
-
  • \Exception

Method doExecute - Source code

/**
 * Internal function to execute the command.
 *
 * @param   InputInterface   $input   The input to inject into the command.
 * @param   OutputInterface  $output  The output to inject into the command.
 *
 * @return  integer  The command exit code
 *
 * @since   4.0.0
 * @throws \Exception
 */
protected function doExecute(InputInterface $input, OutputInterface $output) : int
{
    $this->configureIO($input, $output);
    $options = $this->getOptions();
    if (!$this->retrieveOptionsFromInput($options)) {
        return self::CONFIG_OPTIONS_WRONG;
    }
    if (!$this->validateOptions()) {
        return self::CONFIG_VALIDATION_FAILED;
    }
    $initialOptions = $this->getInitialConfigurationOptions()->toArray();
    $combinedOptions = $this->sanitizeOptions(array_merge($initialOptions, $this->options));
    if (!$this->checkDb($combinedOptions)) {
        return self::DB_VALIDATION_FAILED;
    }
    if ($this->saveConfiguration($combinedOptions)) {
        $this->ioStyle->success('Configuration set');
        return self::CONFIG_SET_SUCCESSFUL;
    }
    return self::CONFIG_SET_FAILED;
}