GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 8873e2...5339ab )
by Mario
04:37
created

FormBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 8
dl 0
loc 74
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A createFormForLocation() 0 23 2
1
<?php
2
3
namespace Netgen\Bundle\InformationCollectionBundle\Form\Builder;
4
5
use eZ\Publish\API\Repository\ContentTypeService;
6
use eZ\Publish\API\Repository\Values\Content\Location;
7
use Netgen\Bundle\EzFormsBundle\Form\DataWrapper;
8
use Netgen\Bundle\InformationCollectionBundle\Form\Payload\InformationCollectionStruct;
9
use Netgen\Bundle\InformationCollectionBundle\Form\Type\InformationCollectionType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\Form\FormFactoryInterface;
12
use Symfony\Component\Routing\RouterInterface;
13
14
class FormBuilder
15
{
16
    /**
17
     * @var FormFactoryInterface
18
     */
19
    protected $formFactory;
20
21
    /**
22
     * @var bool
23
     */
24
    protected $useCsrf;
25
26
    /**
27
     * @var ContentTypeService
28
     */
29
    protected $contentTypeService;
30
31
    /**
32
     * @var RouterInterface
33
     */
34
    protected $router;
35
36
    /**
37
     * FormBuilder constructor.
38
     *
39
     * @param FormFactoryInterface $formFactory
40
     * @param ContentTypeService $contentTypeService
41
     * @param RouterInterface $router
42
     * @param bool $useCsrf
43
     */
44
    public function __construct(
45
        FormFactoryInterface $formFactory,
46
        ContentTypeService $contentTypeService,
47
        RouterInterface $router,
48
        $useCsrf
49
    ) {
50
        $this->formFactory = $formFactory;
51
        $this->useCsrf = $useCsrf;
52
        $this->contentTypeService = $contentTypeService;
53
        $this->router = $router;
54
    }
55
56
    /**
57
     * Creates Information collection Form object for given Location object.
58
     *
59
     * @param Location $location
60
     * @param bool $useAjax
61
     *
62
     * @return FormBuilderInterface
63
     */
64
    public function createFormForLocation(Location $location, $useAjax = false)
65
    {
66
        $contentInfo = $location->contentInfo;
67
68
        $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
69
70
        $data = new DataWrapper(new InformationCollectionStruct(), $contentType, $location);
71
72
        $formBuilder = $this->formFactory
73
            ->createBuilder(
74
                InformationCollectionType::class,
75
                $data,
76
                array(
77
                    'csrf_protection' => $this->useCsrf,
78
                )
79
            );
80
81
        if ($useAjax) {
82
            $formBuilder->setAction($this->router->generate('netgen_information_collection_handle_ajax', array('location' => $location->id)));
83
        }
84
85
        return $formBuilder;
86
    }
87
}
88