You are here

class MergeYamlCommand in Database Sanitize 7

Class MergeYamlCommand.

Hierarchy

  • class \EdisonLabs\MergeYaml\MergeYamlCommand extends \Composer\Command\BaseCommand

Expanded class hierarchy of MergeYamlCommand

1 file declares its use of MergeYamlCommand
MergeYamlCommandTest.php in vendor/edisonlabs/merge-yaml/tests/src/Unit/MergeYamlCommandTest.php

File

vendor/edisonlabs/merge-yaml/src/MergeYamlCommand.php, line 14

Namespace

EdisonLabs\MergeYaml
View source
class MergeYamlCommand extends BaseCommand {

  /**
   * {@inheritdoc}
   */
  public function execute(InputInterface $input, OutputInterface $output, array $configParameters = []) {
    $configFile = $input
      ->getOption('config');
    if ($configFile && empty($configParameters)) {
      $filePath = realpath($configFile);

      // Checks if the file is valid.
      if (!$filePath || !($configfileContent = file_get_contents($filePath))) {
        throw new \RuntimeException("Unable to load the config file {$configFile}");
      }
      $configParameters = json_decode($configfileContent, true);
    }
    $mergeYaml = new PluginHandler($this
      ->getComposer(), $this
      ->getIO(), $configParameters);
    $mergeYaml
      ->createMergeFiles();
  }

  /**
   * {@inheritdoc}
   */
  protected function configure() {
    parent::configure();
    $this
      ->setName('merge-yaml')
      ->setDefinition($this
      ->createDefinition())
      ->setDescription('Merge yaml files.');
  }

  /**
   * {@inheritdoc}
   */
  private function createDefinition() {
    return new InputDefinition(array(
      new InputOption('config', null, InputOption::VALUE_OPTIONAL, 'A json file containing the plugin configuration.'),
    ));
  }

}

Members