Exemple #1
0
 /**
  * Synchronise all RSS remote contents with articles
  */
 public function syncAllAction()
 {
     $em = $this->get('doctrine')->getManager();
     $readers = $em->getRepository('KeosuCoreBundle:Reader')->findBy(array('service' => 'RssReader'));
     foreach ($readers as $reader) {
         //Convert it to a RssReader
         $rssReader = RssReader::constructfromReader($reader);
         //geting the feed as a string
         $rssUrl = $rssReader->feed_url;
         $feed = $this->get('fkr_simple_pie.rss');
         $feed->set_feed_url($rssUrl);
         $feed->init();
         $items = $feed->get_items();
         foreach ($items as $item) {
             $this->parseAndImportArticle($item, $reader, $rssReader->striphtml);
         }
     }
     if ($this->get('security.context')->isGranted('ROLE_ADMIN')) {
         return $this->redirect($this->generateUrl('keosu_article_viewlist'));
     } else {
         return new JsonResponse(array('status' => 'OK', 'message' => 'All RSS readers have been successfully synchronized.'));
     }
 }
Exemple #2
0
 public function editAction($id)
 {
     $commonReader = $this->get('doctrine')->getManager()->getRepository('KeosuCoreBundle:Reader')->find($id);
     $rssReader = RssReader::constructfromReader($commonReader);
     return $this->editReader($rssReader, $commonReader);
 }