You are here

protected function GenericOpmlParser::getOutlines in Feeds 8.3

Returns the sub-outline structure.

Parameters

\DOMElement $context: The context element to iterate on.

Return value

array The nested outline array.

1 call to GenericOpmlParser::getOutlines()
GenericOpmlParser::parse in src/Component/GenericOpmlParser.php
Parses the OPML file.

File

src/Component/GenericOpmlParser.php, line 85

Class

GenericOpmlParser
Parses a generic OPML string into an array.

Namespace

Drupal\feeds\Component

Code

protected function getOutlines(\DOMElement $context) {
  $outlines = [];
  foreach ($this->xpath
    ->query('outline', $context) as $element) {
    $outline = [];
    if ($element
      ->hasAttributes()) {
      foreach ($element->attributes as $attribute) {
        if ($this->normalizeCase) {
          $outline['#' . strtolower($attribute->nodeName)] = $attribute->nodeValue;
        }
        else {
          $outline['#' . $attribute->nodeName] = $attribute->nodeValue;
        }
      }
    }

    // Recurse.
    if ($sub_outlines = $this
      ->getOutlines($element)) {
      $outline['outlines'] = $sub_outlines;
    }
    $outlines[] = $outline;
  }
  return $outlines;
}