This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\NewsBundle\Controller; |
||
15 | |||
16 | // NEXT_MAJOR: remove this file |
||
17 | |||
18 | @trigger_error( |
||
0 ignored issues
–
show
|
|||
19 | 'The '.__NAMESPACE__.'\PostController class is deprecated since version 3.5 and will be removed in 4.0.' |
||
20 | .' Use '.__NAMESPACE__.'\Action\* classes instead.', |
||
21 | E_USER_DEPRECATED |
||
22 | ); |
||
23 | |||
24 | use Sonata\NewsBundle\Action\CollectionPostArchiveAction; |
||
25 | use Sonata\NewsBundle\Action\CommentListAction; |
||
26 | use Sonata\NewsBundle\Action\CreateCommentAction; |
||
27 | use Sonata\NewsBundle\Action\CreateCommentFormAction; |
||
28 | use Sonata\NewsBundle\Action\ModerateCommentAction; |
||
29 | use Sonata\NewsBundle\Action\MonthlyPostArchiveAction; |
||
30 | use Sonata\NewsBundle\Action\PostArchiveAction; |
||
31 | use Sonata\NewsBundle\Action\TagPostArchiveAction; |
||
32 | use Sonata\NewsBundle\Action\ViewPostAction; |
||
33 | use Sonata\NewsBundle\Action\YearlyPostArchiveAction; |
||
34 | use Sonata\NewsBundle\Form\Type\CommentType; |
||
35 | use Sonata\NewsBundle\Model\BlogInterface; |
||
36 | use Sonata\NewsBundle\Model\CommentManagerInterface; |
||
37 | use Sonata\NewsBundle\Model\PostInterface; |
||
38 | use Sonata\NewsBundle\Model\PostManagerInterface; |
||
39 | use Sonata\SeoBundle\Seo\SeoPageInterface; |
||
40 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
||
41 | use Symfony\Component\Form\FormInterface; |
||
42 | use Symfony\Component\HttpFoundation\RedirectResponse; |
||
43 | use Symfony\Component\HttpFoundation\Request; |
||
44 | use Symfony\Component\HttpFoundation\Response; |
||
45 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
46 | use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
||
47 | |||
48 | class PostController extends Controller |
||
0 ignored issues
–
show
The class
Symfony\Bundle\Framework...e\Controller\Controller has been deprecated with message: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead.
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead. ![]() |
|||
49 | { |
||
50 | /** |
||
51 | * @return RedirectResponse |
||
52 | */ |
||
53 | public function homeAction() |
||
54 | { |
||
55 | return $this->redirect($this->generateUrl('sonata_news_archive')); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param Request $request |
||
60 | * |
||
61 | * @return Response |
||
62 | */ |
||
63 | public function renderArchive(array $criteria = [], array $parameters = [], ?Request $request = null) |
||
64 | { |
||
65 | $action = $this->container->get(PostArchiveAction::class); |
||
66 | |||
67 | return $action->renderArchive($this->resolveRequest($request), $criteria, $parameters); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param Request $request |
||
72 | * |
||
73 | * @return Response |
||
74 | */ |
||
75 | public function archiveAction(?Request $request = null) |
||
76 | { |
||
77 | $action = $this->container->get(PostArchiveAction::class); |
||
78 | |||
79 | return $action($this->resolveRequest($request)); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param string $tag |
||
84 | * @param Request $request |
||
85 | * |
||
86 | * @throws NotFoundHttpException |
||
87 | * |
||
88 | * @return Response |
||
89 | */ |
||
90 | public function tagAction($tag, ?Request $request = null) |
||
91 | { |
||
92 | $action = $this->container->get(TagPostArchiveAction::class); |
||
93 | |||
94 | return $action($this->resolveRequest($request), $tag); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param string $collection |
||
99 | * @param Request $request |
||
100 | * |
||
101 | * @throws NotFoundHttpException |
||
102 | * |
||
103 | * @return Response |
||
104 | */ |
||
105 | public function collectionAction($collection, ?Request $request = null) |
||
106 | { |
||
107 | $action = $this->container->get(CollectionPostArchiveAction::class); |
||
108 | |||
109 | return $action($this->resolveRequest($request), $collection); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param string $year |
||
114 | * @param string $month |
||
115 | * @param Request $request |
||
116 | * |
||
117 | * @return Response |
||
118 | */ |
||
119 | public function archiveMonthlyAction($year, $month, ?Request $request = null) |
||
120 | { |
||
121 | $action = $this->container->get(MonthlyPostArchiveAction::class); |
||
122 | |||
123 | return $action($this->resolveRequest($request), $year, $month); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param string $year |
||
128 | * @param Request $request |
||
129 | * |
||
130 | * @return Response |
||
131 | */ |
||
132 | public function archiveYearlyAction($year, ?Request $request = null) |
||
133 | { |
||
134 | $action = $this->container->get(YearlyPostArchiveAction::class); |
||
135 | |||
136 | return $action($this->resolveRequest($request), $year); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @param string $permalink |
||
141 | * |
||
142 | * @throws NotFoundHttpException |
||
143 | * |
||
144 | * @return Response |
||
145 | */ |
||
146 | public function viewAction($permalink) |
||
147 | { |
||
148 | $action = $this->container->get(ViewPostAction::class); |
||
149 | |||
150 | return $action($permalink); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @return SeoPageInterface|null |
||
155 | */ |
||
156 | public function getSeoPage() |
||
157 | { |
||
158 | if ($this->has('sonata.seo.page')) { |
||
159 | return $this->get('sonata.seo.page'); |
||
160 | } |
||
161 | |||
162 | return null; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @param int $postId |
||
167 | * |
||
168 | * @return Response |
||
169 | */ |
||
170 | public function commentsAction($postId) |
||
171 | { |
||
172 | $action = $this->container->get(CommentListAction::class); |
||
173 | |||
174 | return $action($postId); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * @param $postId |
||
179 | * @param bool $form |
||
180 | * |
||
181 | * @return Response |
||
182 | */ |
||
183 | public function addCommentFormAction($postId, $form = false) |
||
184 | { |
||
185 | $action = $this->container->get(CreateCommentFormAction::class); |
||
186 | |||
187 | return $action($postId, $form); |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * @return FormInterface |
||
192 | */ |
||
193 | public function getCommentForm(PostInterface $post) |
||
194 | { |
||
195 | $comment = $this->getCommentManager()->create(); |
||
196 | $comment->setPost($post); |
||
197 | $comment->setStatus($post->getCommentsDefaultStatus()); |
||
198 | |||
199 | return $this->get('form.factory')->createNamed('comment', CommentType::class, $comment, [ |
||
200 | 'action' => $this->generateUrl('sonata_news_add_comment', [ |
||
201 | 'id' => $post->getId(), |
||
202 | ]), |
||
203 | 'method' => 'POST', |
||
204 | ]); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @param string $id |
||
209 | * @param Request $request |
||
210 | * |
||
211 | * @throws NotFoundHttpException |
||
212 | * |
||
213 | * @return Response |
||
214 | */ |
||
215 | public function addCommentAction($id, ?Request $request = null) |
||
216 | { |
||
217 | $action = $this->container->get(CreateCommentAction::class); |
||
218 | |||
219 | return $action($this->resolveRequest($request), $id); |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * @param string $commentId |
||
224 | * @param string $hash |
||
225 | * @param string $status |
||
226 | * |
||
227 | * @throws AccessDeniedException |
||
228 | * |
||
229 | * @return RedirectResponse |
||
230 | */ |
||
231 | public function commentModerationAction($commentId, $hash, $status) |
||
232 | { |
||
233 | $action = $this->container->get(ModerateCommentAction::class); |
||
234 | |||
235 | return $action($commentId, $hash, $status); |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * @return PostManagerInterface |
||
240 | */ |
||
241 | protected function getPostManager() |
||
242 | { |
||
243 | return $this->get('sonata.news.manager.post'); |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * @return CommentManagerInterface |
||
248 | */ |
||
249 | protected function getCommentManager() |
||
250 | { |
||
251 | return $this->get('sonata.news.manager.comment'); |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * @return BlogInterface |
||
256 | */ |
||
257 | protected function getBlog() |
||
258 | { |
||
259 | return $this->get('sonata.news.blog'); |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * To keep backwards compatibility with older Sonata News code. |
||
264 | * |
||
265 | * @internal |
||
266 | * |
||
267 | * @param Request $request |
||
268 | * |
||
269 | * @return Request |
||
270 | */ |
||
271 | private function resolveRequest(?Request $request = null) |
||
272 | { |
||
273 | if (null === $request) { |
||
274 | return $this->get('request_stack')->getCurrentRequest(); |
||
275 | } |
||
276 | |||
277 | return $request; |
||
278 | } |
||
279 | } |
||
280 |
If you suppress an error, we recommend checking for the error condition explicitly: