Completed
Pull Request — master (#9)
by Roman
03:37
created

HandleRequestStep::requiresBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Kami\ApiCoreBundle\RequestProcessor\Step\Common;
4
5
6
use Kami\ApiCoreBundle\RequestProcessor\ResponseInterface;
7
use Kami\ApiCoreBundle\RequestProcessor\Step\AbstractStep;
8
use Symfony\Component\Form\Form;
9
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
10
11
class HandleRequestStep extends AbstractStep
12
{
13
    public function execute()
14
    {
15
        /** @var Form $form */
16
        $form = $this->getFromResponse('form');
17
        $form->handleRequest($this->request);
18
19
        if (!$form->isSubmitted()) {
20
            throw new BadRequestHttpException('Form is supposed to be submitted with this request');
21
        }
22
23
        return $this->createResponse(['form' => $form]);
24
    }
25
26
    public function requiresBefore()
27
    {
28
        return ['generic_build_form_step'];
29
    }
30
31
}