44
55use AlexisLefebvre \Bundle \AsyncTweetsBundle \Entity \Tweet ;
66use AlexisLefebvre \Bundle \AsyncTweetsBundle \Entity \TweetRepository ;
7+ use Doctrine \ORM \EntityManagerInterface ;
78use Symfony \Bundle \FrameworkBundle \Controller \AbstractController as BaseController ;
89use Symfony \Component \HttpFoundation \Cookie ;
910use Symfony \Component \HttpFoundation \RedirectResponse ;
@@ -18,13 +19,21 @@ class_alias('Symfony\Bundle\FrameworkBundle\Controller\Controller', 'Symfony\Bun
1819
1920class DefaultController extends BaseController
2021{
22+ /** @var EntityManagerInterface */
23+ private $ entityManager ;
24+
2125 /** @var TweetRepository */
2226 private $ tweetRepository ;
2327
28+ public function __construct (EntityManagerInterface $ entityManager )
29+ {
30+ $ this ->entityManager = $ entityManager ;
31+ }
32+
2433 public function indexAction (Request $ request , ?int $ firstTweetId ): Response
2534 {
2635 /** @var TweetRepository $tweetRepository */
27- $ tweetRepository = $ this ->getDoctrine ()
36+ $ tweetRepository = $ this ->entityManager
2837 ->getRepository (Tweet::class);
2938
3039 $ this ->tweetRepository = $ tweetRepository ;
@@ -154,7 +163,7 @@ public function deleteLessThanAction(Request $request): RedirectResponse
154163
155164 if (!is_null ($ lastTweetId )) {
156165 /** @var TweetRepository $tweetRepository */
157- $ tweetRepository = $ this ->getDoctrine ()
166+ $ tweetRepository = $ this ->entityManager
158167 ->getRepository (Tweet::class);
159168
160169 $ count = $ tweetRepository
0 commit comments