| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 3 | public function __invoke(Request $request, Article $article): array |
|
| 26 | { |
||
| 27 | 3 | $user = $this->getCurrentUser(); |
|
| 28 | |||
| 29 | 3 | $comment = new Comment(); |
|
| 30 | 3 | $comment->setAuthor($user); |
|
| 31 | 3 | $comment->setArticle($article); |
|
| 32 | |||
| 33 | 3 | $form = $this->createNamedForm('comment', CommentType::class, $comment); |
|
| 34 | 3 | $form->submit($request->request->get('comment')); |
|
| 35 | |||
| 36 | 3 | if ($form->isValid()) { |
|
| 37 | 1 | $this->getDoctrine()->getManager()->persist($comment); |
|
| 38 | 1 | $this->getDoctrine()->getManager()->flush(); |
|
| 39 | |||
| 40 | 1 | return ['comment' => $comment]; |
|
| 41 | } |
||
| 42 | |||
| 43 | 2 | return ['form' => $form]; |
|
| 44 | } |
||
| 46 |