You are here

protected function MergePlugin::mergeFiles in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php \Wikimedia\Composer\MergePlugin::mergeFiles()

Find configuration files matching the configured glob patterns and merge their contents with the master package.

Parameters

array $patterns List of files/glob patterns:

bool $required Are the patterns required to match files?:

Throws

MissingFileException when required and a pattern returns no results

2 calls to MergePlugin::mergeFiles()
MergePlugin::mergeFile in vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php
Read a JSON file and merge its contents
MergePlugin::onInstallUpdateOrDump in vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php
Handle an event callback for an install, update or dump command by checking for "merge-plugin" in the "extra" data and merging package contents if found.

File

vendor/wikimedia/composer-merge-plugin/src/MergePlugin.php, line 169

Class

MergePlugin
Composer plugin that allows merging multiple composer.json files.

Namespace

Wikimedia\Composer

Code

protected function mergeFiles(array $patterns, $required = false) {
  $root = $this->composer
    ->getPackage();
  $files = array_map(function ($files, $pattern) use ($required) {
    if ($required && !$files) {
      throw new MissingFileException("merge-plugin: No files matched required '{$pattern}'");
    }
    return $files;
  }, array_map('glob', $patterns), $patterns);
  foreach (array_reduce($files, 'array_merge', array()) as $path) {
    $this
      ->mergeFile($root, $path);
  }
}