Browse files

Fixed twitter feed handler

  • Loading branch information...
1 parent 02e51f5 commit d171235b2f28ffb7406c3b6ed47f3a8a6b6b1a93 @pascaldevink committed Apr 15, 2012
View
2 src/Pascal/FeedDisplayerBundle/Service/CacheService.php
@@ -18,6 +18,8 @@ protected function __construct()
{
$this->memcached = new \Memcached();
$this->memcached->addServer('localhost', 11211);
+
+// $this->memcached->flush();
}
public static function getInstance()
View
11 src/Pascal/FeedGathererBundle/Service/TwitterFeedService.php
@@ -3,6 +3,7 @@
namespace Pascal\FeedGathererBundle\Service;
use \Pascal\FeedGathererBundle\Entity\TwitterUser;
+use \Pascal\FeedGathererBundle\Entity\Feed;
class TwitterFeedService implements FeedService
{
@@ -33,7 +34,7 @@ public function getServiceType()
return 'twitter';
}
- public function downloadFeed(\Pascal\FeedGathererBundle\Entity\Feed $feed, \DateTime $lastUpdateTime)
+ public function downloadFeed(Feed $feed, \DateTime $lastUpdateTime)
{
$twitter = $this->getTwitter();
$twitterUser = $this->getTwitterUser($feed);
@@ -49,14 +50,15 @@ public function downloadFeed(\Pascal\FeedGathererBundle\Entity\Feed $feed, \Date
if ($code == 200)
{
$timeline = json_decode($response['response'], true);
- $this->processItems($timeline, $twitterUser, $lastUpdateTime);
+ $this->processItems($timeline, $twitterUser, $feed, $lastUpdateTime);
}
}
/**
+ * @param \Pascal\FeedGathererBundle\Entity\Feed $feed
* @return \Pascal\FeedGathererBundle\Entity\TwitterUser[]
*/
- protected function getTwitterUser(\Pascal\FeedGathererBundle\Entity\Feed $feed)
+ protected function getTwitterUser(Feed $feed)
{
$dql = "
SELECT t
@@ -81,7 +83,7 @@ protected function getTwitter()
return $twitter;
}
- protected function processItems($items, TwitterUser $twitterUser, \DateTime $lastUpdateTime)
+ protected function processItems($items, TwitterUser $twitterUser, Feed $feed, \DateTime $lastUpdateTime)
{
foreach($items as $item)
{
@@ -106,6 +108,7 @@ protected function processItems($items, TwitterUser $twitterUser, \DateTime $las
$feedEntry->setTitle('Link shared by ' . $author);
$feedEntry->setUrl($url['expanded_url']);
$feedEntry->setLastUpdateTime($dateTime);
+ $feedEntry->setFeed($feed);
$this->entityManager->persist($feedEntry);
}

0 comments on commit d171235

Please sign in to comment.