Skip to content

Commit

Permalink
Allow to get single parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitot committed Sep 11, 2018
1 parent 24cb79e commit 8093302
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions src/StaticHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,33 @@ public static function getAllExtra($file, $searchForString, $baseDir='') {
$searchable = $currentEl;
}
}
if (is_array($searchable)) {
$includedFoundSearchables = [];
} else {
$includedFoundSearchables = null;
}

if (isset($content['extra']['merge-plugin']['include'])) {
$extraIncludes = $content['extra']['merge-plugin']['include'];
foreach ($extraIncludes as $file) {
$inMergedSearchable = self::getAllExtra($file, $searchForString, $baseDir);
//var_dump($inMergedSearchable);
if (is_array($searchable)) {
if (is_array($inMergedSearchable)) {
$includedFoundSearchables = array_replace($includedFoundSearchables, $inMergedSearchable);
}
$searchableFromIncluded = self::getAllExtra($file, $searchForString, $baseDir);
if (is_null($searchableFromIncluded)) {
continue;
}

if (is_null($searchable)) {
$searchable=$searchableFromIncluded;
continue;
}

if (gettype($searchable) != gettype($searchableFromIncluded)) {
throw new \Exception("Types in included files are incompatible");
} else {
$includedFoundSearchables = $inMergedSearchable;
if (is_array($searchable)) {
$searchable = array_replace($searchable, $searchableFromIncluded);
} elseif (is_string($searchable)) {
$searchable = $searchableFromIncluded;
}
}
}
}

if (is_array($searchable)) {
if (!is_array($includedFoundSearchables)) {
throw new \Exception('Merged config values types are incompatible');
}
return array_replace($searchable, $includedFoundSearchables);
} else {
if (is_string($includedFoundSearchables)) {
return $includedFoundSearchables;
} else {
return $searchable;

}
}
return $searchable;
}
}

0 comments on commit 8093302

Please sign in to comment.