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