Пример #1
0
 /**
  * Populates a feed entry with data coming from Version objects.
  *
  * @param \Zend\Feed\Writer\Entry $entry
  * @param Version                 $version
  */
 protected function populateVersionData(Entry $entry, Version $version)
 {
     $entry->setTitle($entry->getTitle() . " ({$version->getVersion()})");
     $entry->setId($entry->getId() . ' ' . $version->getVersion());
     $entry->setDateModified($version->getReleasedAt());
     $entry->setDateCreated($version->getReleasedAt());
     foreach ($version->getAuthors() as $author) {
         /** @var $author \Packagist\WebBundle\Entity\Author */
         if ($author->getName()) {
             $entry->addAuthor(array('name' => $author->getName()));
         }
     }
 }
Пример #2
0
 public function testSetTitleThrowsExceptionOnInvalidParameter()
 {
     $entry = new Writer\Entry();
     try {
         $entry->setTitle('');
         $this->fail();
     } catch (Writer\Exception $e) {
     }
 }
Пример #3
0
 /**
  * RSS feed
  *
  * @param Request $request
  *
  * @return Response
  *
  * @Route("/blog/rss", name="blog_rss")
  */
 public function rssAction(Request $request)
 {
     $feed = new Feed();
     $config = $this->container->getParameter('stfalcon_blog.config');
     $feed->setTitle($config['rss']['title']);
     $feed->setDescription($config['rss']['description']);
     $feed->setLink($this->generateUrl('blog_rss', array(), true));
     $posts = $this->get('doctrine')->getManager()->getRepository("StfalconBlogBundle:Post")->getAllPublishedPosts($request->getLocale());
     /** @var Post $post */
     foreach ($posts as $post) {
         $entry = new Entry();
         $entry->setTitle($post->getTitle());
         $entry->setLink($this->generateUrl('blog_post_view', array('slug' => $post->getSlug()), true));
         $feed->addEntry($entry);
     }
     $response = new Response($feed->export('rss'));
     $response->headers->add(array('Content-Type' => 'application/xml'));
     return $response;
 }