src/DEVWEB/ColocationBundle/Controller/AdvertController.php
// controller de la vue feed.xml.twig
controller de la vue feed.xml.twig
controller de la vue feed . xml . twig
public function feedAction(Request $request)
  {
    $channel = new Channel();
    $rssWriter = new RssWriter(null, [], true);
     $rssWriter->registerWriter(new CoreWriter());
     $rssWriter->registerWriter(new AtomWriter());
     $channel->setTitle('Annonces')
             ->setDescription('Liste des annonces du site')
             ->setLanguage('fr')
     ;
     $listAdverts = $this->getDoctrine()
       ->getManager()
       ->getRepository('DEVWEBColocationBundle:Advert')
       ->findAll()
     ;
     foreach ($listAdverts as $advert) {
       $item = new Item();
       $item->setTitle($advert->getTitle())
           ->setDescription($advert->getContent())
           ->setAuthor($advert->getAuthor())
           ->setPubDate($advert->getDate())
           ->setPlaces($advert->getNbPlaces());
       ;
       $channel->addItem($item);
     }
     $xml = $rssWriter->writeChannel($channel);
    return new RssStreamedResponse($channel, $this->get('marcw_rss_writer.rss_writer'));
  }
public function feedAction ( Request $ request ) { $ channel = new Channel ( ) ; $ rssWriter = new RssWriter ( null , [ ] , true ) ; $ rssWriter -> registerWriter ( new CoreWriter ( ) ) ; $ rssWriter -> registerWriter ( new AtomWriter ( ) ) ; $ channel -> setTitle ( 'Annonces' ) -> setDescription ( 'Liste des annonces du site' ) -> setLanguage ( 'fr' ) ; $ listAdverts = $ this -> getDoctrine ( ) -> getManager ( ) -> getRepository ( 'DEVWEBColocationBundle:Advert' ) -> findAll ( ) ; foreach ( $ listAdverts as $ advert ) { $ item = new Item ( ) ; $ item -> setTitle ( $ advert -> getTitle ( ) ) -> setDescription ( $ advert -> getContent ( ) ) -> setAuthor ( $ advert -> getAuthor ( ) ) -> setPubDate ( $ advert -> getDate ( ) ) -> setPlaces ( $ advert -> getNbPlaces ( ) ) ; ; $ channel -> addItem ( $ item ) ; } $ xml = $ rssWriter -> writeChannel ( $ channel ) ; return new RssStreamedResponse ( $ channel , $ this -> get ( 'marcw_rss_writer.rss_writer' ) ) ; }
controller de la vue feed.xml.twig
controller de la vue feed . xml . twig