public function run(sfEvent $event)
 {
     if (isset($event['pager'])) {
         $pager = $event['pager'];
         $context = sfContext::getInstance();
         $response = $context->getResponse();
         $request = $context->getRequest();
         $className = 'sf' . ucfirst($event['format']) . 'Feed';
         if (!class_exists($className)) {
             return false;
         }
         $feed = sfFeedPeer::newInstance($event['format']);
         $feed->initialize(array('title' => $response->getTitle(), 'link' => $request->getUri()));
         $items = sfFeedPeer::convertObjectsToItems($pager->getResults());
         $feed->addItems($items);
         $event->setProcessed(true);
         $event->setReturnValue($feed->asXml());
         $request->setRequestFormat($event['format']);
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 public function getDefaultFeed($max = 25)
 {
     $feed = new sfRssFeed();
     $feed->initialize(array('title' => 'Cothink Feed for ' . $this->getFullName(), 'link' => 'http://www.cothink.org/', 'authorEmail' => $this->getPrimaryContactInfo()->getEmail(), 'authorName' => $this->getFullName()));
     $events = HistoryEventPeer::retrieveByUser($this->getUserId(), $max);
     // TODO: Allow user to configure max
     $eventItems = sfFeedPeer::convertObjectsToItems($events, array('routeName' => '@permalink'));
     $feed->addItems($eventItems);
     return $feed;
 }