2017 © Pedro Peláez
 

symfony-bundle feed-bundle

Symfony Bundle to generate RSS Feed with custom namespaces and elements

image

argentum/feed-bundle

Symfony Bundle to generate RSS Feed with custom namespaces and elements

  • Tuesday, June 3, 2014
  • by javer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15,168 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

ArgentumFeedBundle

SensioLabsInsight Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version License, (*1)

ArgentumFeedBundle allows you to create a set of feeds for your content with different settings. All predefined settings can be overridden at runtime., (*2)

You can create your own Feed classes and Renderers by defining a service with tag argentum_feed.feed and argentum_feed.renderer respectively., (*3)

Usage

Render a predefined feed:, (*4)

$rss = $this->get('argentum_feed.factory')
    ->createFeed('news')
    ->addFeedableItems($news)
    ->render();

where $news is a collection of News entities., (*5)

To get it to work your News entity should implement Feedable interface:, (*6)

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;
    }
}

Also you can specify a data source provider in the configuration:, (*7)

argentum_feed:
    channels:
        news:
            title: 'News'
            link: '/'
            description: 'News feed'
            provider:
                repository: 'ArgentumNewsBundle:News'
                method: 'findAllPublished'
                arguments: [10, 'ru']

and then you can just create the feed and render it:, (*8)

$rss = $this->get('argentum_feed.factory')
    ->createFeed('news')
    ->render();

Configuration

Full configuration:, (*9)

argentum_feed:
    channels:
        news:
            title: 'News'
            link: '/'
            description: 'News feed'
            language: 'ru'
            copyright: 'ACME'
            managingEditor: 'Editor'
            webMaster: 'Webmaster'
            pubDate: 'now'
            lastBuildDate: 'now'
            categories:
                - { title: 'Category 1', domain: 'domain' }
                - { title: 'Category 2' }
            generator: 'ArgentumFeedBundle'
            docs: 'docs'
            cloud:
                domain: 'domain.tld'
                port: 80
                path: '/'
                registerProcedure: 'register'
                protocol: 'xmlrpc'
            ttl: 300
            image:
                url: '/images/logo.png'
                title: 'News'
                link: '/'
                width: 128
                height: 96
                description: 'News'
            rating: 'Best'
            textInput:
                title: 'Title'
                description: 'Description'
                name: 'name'
                link: 'http://domain.tld'
            skipHours: [0, 1, 2, 3, 4, 5, 6, 7, 8]
            skipDays:
                - 'Saturday'
                - 'Sunday'
            namespaces:
                default: 'http://backend.userland.com/rss2'
                yandex: 'http://news.yandex.ru'
                mailru: 'http://news.mail.ru'
            customElements:
                - 'yandex:full-text'
                - 'mailru:full-text'
            encoding: 'utf-8'
            translationDomain: 'news'
            feed: 'feed'
            renderer: 'rss'
            provider:
                repository: 'ArgentumNewsBundle:News'
                method: 'findAllPublished'
                arguments: [10, 'ru']

Minimal configuration:, (*10)

argentum_feed:
    channels:
        news:
            title: 'News'
            link: '/'
            description: 'News feed'

All relative links will be converted to absolute using request host. All text content from the predefined configuration will be translated using specified translationDomain., (*11)

The Versions

03/06 2014

dev-master

9999999-dev http://argentum.ua

Symfony Bundle to generate RSS Feed with custom namespaces and elements

  Sources   Download

MIT

The Requires

 

The Development Requires

feed rss

22/05 2014

v1.0.0

1.0.0.0 http://argentum.ua

Symfony Bundle to generate RSS Feed with custom namespaces and elements

  Sources   Download

MIT

The Requires

 

feed rss