/** * @param SimpleXMLElement $xmlBody * @param FeedInterface $feed * * @throws ParserException */ protected function parseHeaders(SimpleXMLElement $xmlBody, FeedInterface $feed) { $feed->setPublicId($xmlBody->id); $feed->setLink(current($this->detectLink($xmlBody, 'self'))); $feed->setTitle($xmlBody->title); $feed->setDescription($xmlBody->subtitle); $format = $this->guessDateFormat($xmlBody->updated); $updated = self::convertToDateTime($xmlBody->updated, $format); $feed->setLastModified($updated); }
/** * @param SimpleXMLElement $xmlBody * @param FeedInterface $feed * @param array $filters * * @return FeedInInterface */ protected function parseBody(SimpleXMLElement $xmlBody, FeedInterface $feed, array $filters) { $feed->setPublicId($xmlBody->channel->link); $feed->setLink($xmlBody->channel->link); $feed->setTitle($xmlBody->channel->title); $feed->setDescription($xmlBody->channel->description); if (isset($xmlBody->channel->date)) { $date = $xmlBody->channel->children('dc', true); $updated = static::convertToDateTime($date[0], $this->guessDateFormat($date[0])); $feed->setLastModified($updated); } $format = null; foreach ($xmlBody->item as $xmlElement) { $item = $this->newItem(); $date = $xmlElement->children('dc', true); $format = !is_null($format) ? $format : $this->guessDateFormat($date[0]); $item->setTitle($xmlElement->title)->setDescription($xmlElement->description)->setUpdated(static::convertToDateTime($date[0], $format))->setLink($xmlElement->link); $this->addValidItem($feed, $item, $filters); } return $feed; }
/** * @param FeedInterface $feed * @param string $rssDate */ protected function setLastModified(FeedInterface $feed, $rssDate) { $format = $this->guessDateFormat($rssDate); $updated = self::convertToDateTime($rssDate, $format); $feed->setLastModified($updated); }