Newscoop\Service\Implementation\ThemeServiceLocalFileSystem::getNodes PHP Method

getNodes() protected method

Finds all the childrens from the provided node that have the provided tag name
protected getNodes ( SimpleXMLElement $node, string $tagName, string $attribute = NULL, $value = '' ) : array
$node SimpleXMLElement The node in which to search the childrens, not null.
$tagName string The tag name for the childrens to find, not null.
$attribute string Optional attribute name to search the kids by, beside the tag name.
$value Optional but if $attribute is specified than specify also the value of the attribute to find by.
return array an array containing all the found nodes, not null can be empty.
    protected function getNodes(\SimpleXMLElement $node, $tagName, $attribute = NULL, $value = '')
    {
        $found = array();
        foreach ($node->children() as $kid) {
            /* @var $kid \SimpleXMLElement */
            if ($kid->getName() === $tagName) {
                if ($attribute != NULL) {
                    if ($kid[$attribute] == $value) {
                        $found[] = $kid;
                    }
                } else {
                    $found[] = $kid;
                }
            }
        }
        return $found;
    }