PHP code example of argentum / feed-bundle
1. Go to this page and download the library: Download argentum/feed-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
argentum / feed-bundle example snippets
$rss = $this->get('argentum_feed.factory')
->createFeed('news')
->addFeedableItems($news)
->render();
use Argentum\FeedBundle\Feed\Feedable;
use Argentum\FeedBundle\Feed\FeedItem;
use Argentum\FeedBundle\Feed\FeedItemEnclosure;
use Argentum\FeedBundle\Feed\FeedItemSource;
class News implements Feedable
{
// ...
/**
* Returns FeedItem instance.
*
* @return FeedItem
*/
public function getFeedItem()
{
$item = new FeedItem();
$item
->setRouteName('news_show')
->setRouteParameters([
'category' => $this->getCategory()->getSlug(),
'id' => $this->getId(),
'slug' => $this->getSlug(),
])
->setTitle($this->getTitle())
->setDescription($this->getAnnounce())
->setPubDate($this->getPublishedAt())
->addCustomValue('yandex:full-text', $this->getBody())
->addCustomValue('mailru:full-text', $this->getBody());
if ($this->getImageMedium()) {
$item->addEnclosure(
new FeedItemEnclosure($this->getImageMedium()['path'], 'image/jpeg')
);
}
if ($this->getSourceTitle()) {
$item->setSource(
new FeedItemSource($this->getSourceTitle(), $this->getSourceUrl())
);
}
return $item;
}
}
$rss = $this->get('argentum_feed.factory')
->createFeed('news')
->render();