Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Provided by @nitriques
  • Loading branch information
nathanhornby committed Aug 26, 2014
1 parent f7edf1f commit 04cda7c
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,24 +451,26 @@ public function makePreAdjustements($context) {

// return all ancestors of the given element with the given names
// names can be a comma seperated list or an array of strings
private static function findChildren(XMLElement $element, $names) {
if(!is_array($names)) {
$names = explode(',', $names);
}

$children = array();

foreach($element->getChildren() as $child) {
if(!($child instanceof XMLElement)) continue;

$children = array_merge($children, self::findChildren($child,$names));

if(in_array($child->getName(), $names )) {
$children[] = $child;
}
}

return $children;
private static function findChildren($element, $names) {
if(!is_array($names)) {
$names = explode(',', $names);
}

$children = array();

if (!($element instanceof XMLElement)) {
return $children;
}

foreach($element->getChildren() as $child) {
$children = array_merge($children, self::findChildren($child,$names));

if($child instanceof XMLElement && in_array($child->getName(), $names )) {
$children[] = $child;
}
}

return $children;
}

// replaces the first ancestor of the first argument which
Expand Down

0 comments on commit 04cda7c

Please sign in to comment.