Back to FeedParser class

Method processElement

protected void
processElement
(\Joomla\CMS\Feed\Feed $feed, \SimpleXMLElement $el, array $namespaces)
Method to parse a specific feed element.
Parameters
  • \Joomla\CMS\Feed\Feed $feed The Feed object being built from the parsed feed.
  • \SimpleXMLElement $el The current XML element object to handle.
  • array $namespaces The array of relevant namespace objects to process for the element.
Returns
  • void
Since
  • 3.1.4
Class: FeedParser
Project: Joomla

Method processElement - Source code

/**
 * Method to parse a specific feed element.
 *
 * @param   Feed               $feed        The Feed object being built from the parsed feed.
 * @param   \SimpleXMLElement  $el          The current XML element object to handle.
 * @param   array              $namespaces  The array of relevant namespace objects to process for the element.
 *
 * @return  void
 *
 * @since   3.1.4
 */
protected function processElement(Feed $feed, \SimpleXMLElement $el, array $namespaces)
{
    // Build the internal method name.
    $method = 'handle' . ucfirst($el->getName());
    // If we are dealing with an item then it is feed entry time.
    if ($el->getName() == $this->entryElementName) {
        // Create a new feed entry for the item.
        $entry = new FeedEntry();
        // First call the internal method.
        $this->processFeedEntry($entry, $el);
        foreach ($namespaces as $namespace) {
            if ($namespace instanceof NamespaceParserInterface) {
                $namespace->processElementForFeedEntry($entry, $el);
            }
        }
        // Add the new entry to the feed.
        $feed->addEntry($entry);
        return;
    }
    // Otherwise we treat it like any other element.
    // First call the internal method.
    if (\is_callable(array($this, $method))) {
        $this->{$method}($feed, $el);
    }
    foreach ($namespaces as $namespace) {
        if ($namespace instanceof NamespaceParserInterface) {
            $namespace->processElementForFeed($feed, $el);
        }
    }
}