AbstractCrudController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A crudAuthorizationChecker() 0 4 1
A crudDoctrine() 0 4 1
A crudPaginator() 0 4 1
A crudFormFactory() 0 4 1
A crudUrlGenerator() 0 4 1
A crudTwig() 0 4 1
A crudListingFactory() 0 4 1
1
<?php
2
3
namespace Saxulum\Crud\Controller;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use Knp\Component\Pager\PaginatorInterface;
7
use Saxulum\Crud\Listing\ListingFactory;
8
use Symfony\Component\Form\FormFactoryInterface;
9
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
10
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
11
12
abstract class AbstractCrudController
13
{
14
    use CrudTrait;
15
16
    /**
17
     * @var AuthorizationCheckerInterface
18
     */
19
    protected $authorizationChecker;
20
21
    /**
22
     * @var ManagerRegistry
23
     */
24
    protected $doctrine;
25
26
    /**
27
     * @var FormFactoryInterface
28
     */
29
    protected $formFactory;
30
31
    /**
32
     * @var PaginatorInterface
33
     */
34
    protected $paginator;
35
36
    /**
37
     * @var UrlGeneratorInterface
38
     */
39
    protected $urlGenerator;
40
41
    /**
42
     * @var \Twig_Environment
43
     */
44
    protected $twig;
45
46
    /**
47
     * @var ListingFactory
48
     */
49
    protected $listingFactory;
50
51
    /**
52
     * @param AuthorizationCheckerInterface $authorizationChecker
53
     * @param ManagerRegistry               $doctrine
54
     * @param FormFactoryInterface          $formFactory
55
     * @param PaginatorInterface            $paginator
56
     * @param UrlGeneratorInterface         $urlGenerator
57
     * @param \Twig_Environment             $twig
58
     * @param ListingFactory                $listingFactory
59
     */
60
    public function __construct(
61
        AuthorizationCheckerInterface $authorizationChecker,
62
        ManagerRegistry $doctrine,
63
        FormFactoryInterface $formFactory = null,
64
        PaginatorInterface $paginator = null,
65
        UrlGeneratorInterface $urlGenerator = null,
66
        \Twig_Environment $twig = null,
67
        ListingFactory $listingFactory = null
68
    ) {
69
        $this->authorizationChecker = $authorizationChecker;
70
        $this->doctrine = $doctrine;
71
        $this->paginator = $paginator;
72
        $this->formFactory = $formFactory;
73
        $this->urlGenerator = $urlGenerator;
74
        $this->twig = $twig;
75
        $this->listingFactory = $listingFactory;
76
    }
77
78
    /**
79
     * @return AuthorizationCheckerInterface
80
     */
81
    protected function crudAuthorizationChecker()
82
    {
83
        return $this->authorizationChecker;
84
    }
85
86
    /**
87
     * @return ManagerRegistry
88
     */
89
    protected function crudDoctrine()
90
    {
91
        return $this->doctrine;
92
    }
93
94
    /**
95
     * @return PaginatorInterface
96
     */
97
    protected function crudPaginator()
98
    {
99
        return $this->paginator;
100
    }
101
102
    /**
103
     * @return FormFactoryInterface
104
     */
105
    protected function crudFormFactory()
106
    {
107
        return $this->formFactory;
108
    }
109
110
    /**
111
     * @return UrlGeneratorInterface
112
     */
113
    protected function crudUrlGenerator()
114
    {
115
        return $this->urlGenerator;
116
    }
117
118
    /**
119
     * @return \Twig_Environment
120
     */
121
    protected function crudTwig()
122
    {
123
        return $this->twig;
124
    }
125
126
    /**
127
     * @return ListingFactory
128
     */
129
    protected function crudListingFactory()
130
    {
131
        return $this->listingFactory;
132
    }
133
}
134