This commit is contained in:
Oliver Davies 2019-01-15 23:45:45 +00:00
parent c199a9fd78
commit e3cca4f40c

View file

@ -3,6 +3,7 @@
namespace App\Service; namespace App\Service;
use App\Entity\Tweet; use App\Entity\Tweet;
use App\Repository\TweetRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Tightenco\Collect\Support\Collection; use Tightenco\Collect\Support\Collection;
@ -34,17 +35,25 @@ class TweetFetcher
*/ */
private $entityManager; 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->codebird = $codebird;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->tweetRepository = $tweetRepository;
} }
public function getTweets(): Collection public function getTweets(): Collection
{ {
$newestTweet = $this->tweetRepository->findNewestTweet();
$response = collect($this->codebird->get()->search_tweets([ $response = collect($this->codebird->get()->search_tweets([
'q' => collect($this->params()->all())->implode(' AND '), 'q' => collect($this->params()->all())->implode(' AND '),
// 'since_id' => $this->lastTweetId, // 'since_id' => $newestTweet ? $newestTweet->getId() : null,
])); ]));
if ($response->get('httpstatus') != 200) { if ($response->get('httpstatus') != 200) {