You are here

public function PluginHandler::__construct in Database Sanitize 7

Parameters

\Composer\Composer $composer: The Composer object.

\Composer\IO\IOInterface $io: The IO object.

array $configParameters: The config parameters to override the extra config from composer.json.

File

vendor/edisonlabs/merge-yaml/src/PluginHandler.php, line 59

Class

PluginHandler
Class PluginHandler.

Namespace

EdisonLabs\MergeYaml

Code

public function __construct(Composer $composer, IOInterface $io, array $configParameters = array()) {
  $this->io = $io;
  $config = $configParameters;
  if (!$config) {
    $extra = $composer
      ->getPackage()
      ->getExtra();
    if (!isset($extra['merge-yaml'])) {
      return;
    }
    $config = $extra['merge-yaml'];
  }

  // Get files.
  if (empty($config['files'])) {
    throw new \RuntimeException('Please configure merge-yaml files in your composer.json');
  }
  $this->fileNamePatterns = $config['files'];

  // Get locations.
  if (empty($config['locations']) || !is_array($config['locations'])) {
    throw new \RuntimeException('Please configure merge-yaml locations in your composer.json');
  }
  $this->sourcePaths = $config['locations'];

  // Get output dir.
  if (empty($config['output-dir'])) {
    throw new \RuntimeException('Please configure merge-yaml output-dir in your composer.json');
  }
  $this->outputDir = $config['output-dir'];
  $this->isConfigured = true;
}