These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\LeadGenerationBundle\AdminList; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Doctrine\ORM\QueryBuilder; |
||
7 | use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper; |
||
8 | use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator; |
||
9 | use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM; |
||
10 | use Kunstmaan\LeadGenerationBundle\Entity\Popup\AbstractPopup; |
||
11 | |||
12 | class RulesAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator |
||
13 | { |
||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $popupId; |
||
18 | |||
19 | /** |
||
20 | * @param EntityManager $em The entity manager |
||
21 | * @param AclHelper $aclHelper The acl helper |
||
0 ignored issues
–
show
|
|||
22 | * @param int $id The if of the popup |
||
23 | */ |
||
24 | View Code Duplication | public function __construct(EntityManager $em, AclHelper $aclHelper = null, $id) |
|
25 | { |
||
26 | parent::__construct($em, $aclHelper); |
||
27 | |||
28 | $this->setPopupId($id); |
||
29 | $this->setListTemplate('@KunstmaanLeadGeneration/AdminList/rules-list.html.twig'); |
||
30 | $this->setEditTemplate('@KunstmaanLeadGeneration/AdminList/rules-edit.html.twig'); |
||
31 | $this->setAddTemplate('@KunstmaanLeadGeneration/AdminList/rules-edit.html.twig'); |
||
32 | } |
||
33 | |||
34 | public function adaptQueryBuilder(QueryBuilder $queryBuilder, array $params = []) |
||
35 | { |
||
36 | $queryBuilder->where('b.popup = :id'); |
||
37 | $queryBuilder->setParameter('id', $this->getPopupId()); |
||
38 | $queryBuilder->orderBy('b.id', 'ASC'); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Return the url to list all the items |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | public function getIndexUrl() |
||
47 | { |
||
48 | return [ |
||
49 | 'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_detail', |
||
50 | 'params' => ['popup' => $this->getPopupId()], |
||
51 | ]; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get the edit url for the given $item |
||
56 | * |
||
57 | * @param object $item |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | View Code Duplication | public function getEditUrlFor($item) |
|
62 | { |
||
63 | $params = ['id' => $item->getId(), 'popup' => $this->getPopupId()]; |
||
64 | $params = array_merge($params, $this->getExtraParameters()); |
||
65 | |||
66 | return [ |
||
67 | 'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_edit', |
||
68 | 'params' => $params, |
||
69 | ]; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Get the delete url for the given $item |
||
74 | * |
||
75 | * @param object $item |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | View Code Duplication | public function getDeleteUrlFor($item) |
|
80 | { |
||
81 | $params = ['id' => $item->getId(), 'popup' => $this->getPopupId()]; |
||
82 | $params = array_merge($params, $this->getExtraParameters()); |
||
83 | |||
84 | return [ |
||
85 | 'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_delete', |
||
86 | 'params' => $params, |
||
87 | ]; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Configure the visible columns |
||
92 | */ |
||
93 | public function buildFields() |
||
94 | { |
||
95 | $this->addField('id', 'kuma_lead_generation.rules.list.header.id', true); |
||
96 | $this->addField('classname', 'kuma_lead_generation.rules.list.header.type', false); |
||
97 | $this->addField('jsProperties', 'kuma_lead_generation.rules.list.header.properties', false); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Build filters for admin list |
||
102 | */ |
||
103 | public function buildFilters() |
||
104 | { |
||
105 | $this->addFilter('id', new ORM\StringFilterType('id'), 'kuma_lead_generation.rules.list.filter.id'); |
||
106 | } |
||
107 | |||
108 | public function getValue($item, $columnName) |
||
109 | { |
||
110 | if ($columnName == 'jsProperties') { |
||
111 | return json_encode($item->getJsProperties()); |
||
112 | } |
||
113 | |||
114 | return parent::getValue($item, $columnName); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Get bundle name |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getBundleName() |
||
123 | { |
||
124 | return 'KunstmaanLeadGenerationBundle'; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Get entity name |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getEntityName() |
||
133 | { |
||
134 | return 'Rule\AbstractRule'; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param object $entity |
||
139 | * |
||
140 | * @return object |
||
141 | */ |
||
142 | public function decorateNewEntity($entity) |
||
143 | { |
||
144 | $entity->setPopup($this->getPopup()); |
||
145 | |||
146 | return $entity; |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * @param object|array $item |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | public function canEdit($item) |
||
155 | { |
||
156 | return true; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Configure if it's possible to delete the given $item |
||
161 | * |
||
162 | * @param object|array $item |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | public function canDelete($item) |
||
167 | { |
||
168 | return true; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * Configure if it's possible to add new items |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function canAdd() |
||
177 | { |
||
178 | return true; |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * @return int |
||
183 | */ |
||
184 | public function getPopupId() |
||
185 | { |
||
186 | return $this->popupId; |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param int $popupId |
||
191 | */ |
||
192 | public function setPopupId($popupId) |
||
193 | { |
||
194 | $this->popupId = $popupId; |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return AbstractPopup |
||
199 | */ |
||
200 | public function getPopup() |
||
201 | { |
||
202 | return $this->em->getRepository(AbstractPopup::class)->find($this->getPopupId()); |
||
203 | } |
||
204 | } |
||
205 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.