eko / FeedBundle

A Symfony bundle to build RSS feeds from your entities
http://vincent.composieux.fr
MIT License
141 stars 50 forks source link

Use MediaItemField #29

Closed jokari4242 closed 10 years ago

jokari4242 commented 10 years ago

Hello,

Since few days, I have this error :

mod_fcgid: stderr: PHP Catchable fatal error: Argument 1 passed to Eko\FeedBundle\Feed\Feed::addItemField() must be an instance of Eko\FeedBundle\Field\Item\ItemFieldInterface, instance of Eko\FeedBundle\Field\MediaItemField given

This is my controller :

public function feedAction()
{
    $annonces = $this->getDoctrine()->getRepository('LgmAnnonceBundle:Annonce')->derniereAnnonce();

    $feed = $this->get('eko_feed.feed.manager')->get('annonces');

    $feed->addFromArray($annonces);
    $feed->addItemField(new MediaItemField('getFeedMediaItem'));

    $response = new Response($feed->render('atom'));
    $response->headers->set('Content-Type', 'application/rss+xml');
    return $response;
}

I don't understand where is the source of the problem...

I have the same configuration of documentation. If someone can help me!

Thanks,

eko commented 10 years ago

Hi @jokari4242,

I don't know where is your problem but I think everything is okay about this on FeedBundle because we have unit tests using MediaItemField class (see: https://github.com/eko/FeedBundle/blob/master/Tests/Format/RSSFormatterTest.php#L138)

Do you have the correct use statement in your controller? Because it has been changed in the latest tag: Old: Eko\FeedBundle\Field\MediaItemField New (you must have this one): Eko\FeedBundle\Field\Item\MediaItemField,

Thank you

jokari4242 commented 10 years ago

I put the New use Statement and everythings it's OK, thanks you for your help, and for your Bundle!

eko commented 10 years ago

@jokari4242,

Thank you, have a good feed :)