/** * Handles enclosures if any. * * @param SimpleXMLElement $element * @param ItemInInterface $item * * @return $this */ protected function handleEnclosure(SimpleXMLElement $element, ItemInInterface $item) { if (isset($element->enclosure)) { $media = $this->createMedia($element->enclosure); $item->addMedia($media); } return $this; }
/** * Parse category elements. * We may have more than one. * * @param SimpleXMLElement $element * @param ItemInInterface $item */ protected function parseCategories(SimpleXMLElement $element, ItemInInterface $item) { foreach ($element->category as $xmlCategory) { $category = new Category(); $category->setName($this->getAttributeValue($xmlCategory, 'term')); $item->addCategory($category); } }
/** * Parse author: * first we look at optional dc:creator, which is the author name * if no, we fallback to the RSS author element which is the author email * * @param SimpleXMLElement $element * @param ItemInInterface $item */ protected function handleAuthor(SimpleXMLElement $element, ItemInInterface $item) { $dcChild = $element->children('http://purl.org/dc/elements/1.1/'); if (isset($dcChild->creator)) { $item->setAuthor((string) $dcChild->creator); } else { $item->setAuthor((string) $element->author); } }
/** * Handles enclosures if any. * * @param SimpleXMLElement $element * @param ItemInInterface $item * * @return $this */ protected function handleEnclosure(SimpleXMLElement $element, ItemInInterface $item) { foreach ($element->link as $link) { if (strcasecmp($this->getAttributeValue($link, 'rel'), 'enclosure') === 0) { $media = $this->createMedia($link); $item->addMedia($media); } } return $this; }