From e3cca4f40cc7ff3f6d572922781b84fa87a9845b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 15 Jan 2019 23:45:45 +0000 Subject: [PATCH] wip --- src/Service/TweetFetcher.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Service/TweetFetcher.php b/src/Service/TweetFetcher.php index 78fa9af..c06d415 100644 --- a/src/Service/TweetFetcher.php +++ b/src/Service/TweetFetcher.php @@ -3,6 +3,7 @@ namespace App\Service; use App\Entity\Tweet; +use App\Repository\TweetRepository; use Doctrine\ORM\EntityManagerInterface; use Tightenco\Collect\Support\Collection; @@ -34,17 +35,25 @@ class TweetFetcher */ private $entityManager; - public function __construct(Codebird $codebird, EntityManagerInterface $entityManager) + /** + * @var \App\Service\TweetRepository + */ + private $tweetRepository; + + public function __construct(Codebird $codebird, EntityManagerInterface $entityManager, TweetRepository $tweetRepository) { $this->codebird = $codebird; $this->entityManager = $entityManager; + $this->tweetRepository = $tweetRepository; } public function getTweets(): Collection { + $newestTweet = $this->tweetRepository->findNewestTweet(); + $response = collect($this->codebird->get()->search_tweets([ 'q' => collect($this->params()->all())->implode(' AND '), - // 'since_id' => $this->lastTweetId, +// 'since_id' => $newestTweet ? $newestTweet->getId() : null, ])); if ($response->get('httpstatus') != 200) {