Closed shairyar closed 9 years ago
Hi @shairyar,
This is because you have to use an hydrator class (or the following default hydrator class: https://github.com/eko/FeedBundle/blob/master/Hydrator/DefaultHydrator.php).
Your code should be:
$reader = $this->get('eko_feed.feed.reader');
$reader->setHydrator(new DefaultHydrator());
$items = $reader->load('http://rss.indeed.com/rss?q=Singapore')->populate('AppBundle\Entity\Rss');
Hope it helps.
Hi @eko
Thanks, that solved the problem, how do i persist it to the database then
I tried the following
$reader = $this->get('eko_feed.feed.reader'); $reader->setHydrator(new DefaultHydrator()); $items = $reader->load('http://rss.indeed.com/rss?q=Singapore')->populate('AppBundle\Entity\Rss'); dump($items); $em = $this->getDoctrine()->getManager(); $em->persist($items); $em->flush(); return $this->render('default/index.html.twig');
but that gives me an error of
EntityManager#persist() expects parameter 1 to be an entity object, array given.
@shairyar,
You have to persist item per item:
$reader = $this->get('eko_feed.feed.reader');
$reader->setHydrator(new DefaultHydrator());
$items = $reader->load('http://rss.indeed.com/rss?q=Singapore')->populate('AppBundle\Entity\Rss');
$em = $this->getDoctrine()->getManager();
foreach ($items as $item) {
$em->persist($item);
}
$em->flush();
return $this->render('default/index.html.twig');
Can you please close this issue?
Thank you
Just one last question, is it possible to fetch feeds after the specific date? or that needs to be handled by me in my code logic?
This is not possible through this bundle, you have to develop this logic.
Hi,
I am trying to save the RSS feeds being fetched to my database, following the instructions this is the code inside my controller
This is my Rss Entity
When i run the action the error i get is as following and i don't understand why. What am i doing wrong?