protected function processConfiguration($configurationType, \Closure $processor, $saveResult = false)
{
if (is_dir($this->targetPackageData['path'] . '/Configuration') === false) {
return;
}
$yamlPathsAndFilenames = Files::readDirectoryRecursively($this->targetPackageData['path'] . '/Configuration', 'yaml', true);
$configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames, function ($pathAndFileName) use($configurationType) {
if (strpos(basename($pathAndFileName, '.yaml'), $configurationType) === 0) {
return true;
} else {
return false;
}
});
$yamlSource = new YamlSource();
foreach ($configurationPathsAndFilenames as $pathAndFilename) {
$originalConfiguration = $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5));
$processor($configuration);
if ($saveResult === true && $configuration !== $originalConfiguration) {
$yamlSource->save(substr($pathAndFilename, 0, -5), $configuration);
}
}
}