1 | <?php |
||
10 | class DefaultController extends Controller |
||
11 | { |
||
12 | private $tweetRepository; |
||
13 | |||
14 | /** |
||
15 | * @param Request $request |
||
16 | * @param string|null $firstTweetId |
||
17 | * |
||
18 | * @return \Symfony\Component\HttpFoundation\Response $response $response |
||
19 | */ |
||
20 | 7 | public function indexAction(Request $request, $firstTweetId = null) |
|
44 | |||
45 | /** |
||
46 | * @param Request $request |
||
47 | * @param Tweets[] $tweets |
||
48 | * @param integer $firstTweetId |
||
49 | * |
||
50 | * @return array $vars |
||
51 | */ |
||
52 | 7 | private function getVariables(Request $request, $tweets, $firstTweetId) |
|
70 | |||
71 | /** |
||
72 | * If a Tweet is displayed, fetch data from repository |
||
73 | * |
||
74 | * @param Tweets[] $tweets |
||
75 | * @param array $vars |
||
76 | * |
||
77 | * @return array $vars |
||
78 | */ |
||
79 | 6 | private function getTweetsVars($tweets, $vars) |
|
102 | |||
103 | /** |
||
104 | * @param Request $request |
||
105 | * @return integer|null |
||
106 | */ |
||
107 | 7 | private function getLastTweetIdFromCookie(Request $request) |
|
115 | |||
116 | /** |
||
117 | * @param string $firstTweetId |
||
118 | * @return Cookie $cookie |
||
119 | */ |
||
120 | 6 | private function createCookie($firstTweetId) |
|
121 | { |
||
122 | 6 | $nextYear = new \Datetime('now'); |
|
123 | 6 | $nextYear->add(new \DateInterval('P1Y')); |
|
124 | |||
125 | # Set last Tweet Id |
||
126 | 6 | $cookie = new Cookie('lastTweetId', $firstTweetId, |
|
127 | 6 | $nextYear->format('U')); |
|
128 | |||
129 | 6 | return($cookie); |
|
130 | } |
||
131 | |||
132 | /** |
||
133 | * @return RedirectResponse $response |
||
134 | */ |
||
135 | 1 | public function resetCookieAction() |
|
148 | |||
149 | /** |
||
150 | * @param Request $request |
||
151 | * @return RedirectResponse $response |
||
152 | */ |
||
153 | 2 | public function deleteLessThanAction(Request $request) |
|
169 | } |
||
170 |