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\ArticleBundle\AdminList; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Doctrine\ORM\QueryBuilder; |
||
7 | use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper; |
||
8 | use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionDefinition; |
||
9 | use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator; |
||
10 | use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\BooleanFilterType; |
||
11 | use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\DateFilterType; |
||
12 | use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\StringFilterType; |
||
13 | use Kunstmaan\ArticleBundle\Entity\AbstractArticleOverviewPage; |
||
14 | use Kunstmaan\NodeBundle\Entity\Node; |
||
15 | |||
16 | /** |
||
17 | * The AdminList configurator for the AbstractArticlePage |
||
18 | */ |
||
19 | abstract class AbstractArticlePageAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $locale; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $permission; |
||
30 | |||
31 | /** |
||
32 | * @param EntityManager $em The entity manager |
||
33 | * @param AclHelper $aclHelper The ACL helper |
||
34 | * @param string $locale The current locale |
||
35 | * @param string $permission The permission |
||
36 | */ |
||
37 | View Code Duplication | public function __construct(EntityManager $em, AclHelper $aclHelper, $locale, $permission) |
|
38 | { |
||
39 | parent::__construct($em, $aclHelper); |
||
40 | $this->locale = $locale; |
||
41 | $this->setPermissionDefinition( |
||
42 | new PermissionDefinition(array($permission), 'Kunstmaan\NodeBundle\Entity\Node', 'n') |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Return current bundle name. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | public function getBundleName() |
||
52 | { |
||
53 | return 'KunstmaanArticleBundle'; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Return current entity name. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getEntityName() |
||
62 | { |
||
63 | return 'AbstractArticlePage'; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Configure filters |
||
68 | */ |
||
69 | View Code Duplication | public function buildFilters() |
|
70 | { |
||
71 | $this->addFilter('title', new StringFilterType('title'), 'article.page.list.filter.title') |
||
72 | ->addFilter('online', new BooleanFilterType('online'), 'article.page.list.filter.online') |
||
73 | ->addFilter('created', new DateFilterType('created', 'nv'), 'article.page.list.filter.created_at') |
||
74 | ->addFilter('updated', new DateFilterType('updated', 'nv'), 'article.page.list.filter.updated_at'); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Configure the visible columns |
||
79 | */ |
||
80 | View Code Duplication | public function buildFields() |
|
81 | { |
||
82 | $this->addField('title', 'article.page.list.header.title', true, 'KunstmaanNodeBundle:Admin:title.html.twig') |
||
0 ignored issues
–
show
|
|||
83 | ->addField('created', 'article.page.list.header.created_at', true) |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
84 | ->addField('updated', 'article.page.list.header.updated_at', true) |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
85 | ->addField('online', 'article.page.list.header.online', true, 'KunstmaanNodeBundle:Admin:online.html.twig'); |
||
0 ignored issues
–
show
true is of type boolean , but the function expects a string .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @return QueryBuilder |
||
90 | */ |
||
91 | protected function getQueryBuilder() |
||
92 | { |
||
93 | $queryBuilder = $this->em |
||
94 | ->getRepository('KunstmaanNodeBundle:NodeTranslation') |
||
95 | ->createQueryBuilder('b'); |
||
96 | |||
97 | return $queryBuilder; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param QueryBuilder $queryBuilder The query builder |
||
102 | */ |
||
103 | public function adaptQueryBuilder(QueryBuilder $queryBuilder) |
||
104 | { |
||
105 | parent::adaptQueryBuilder($queryBuilder); |
||
106 | |||
107 | $queryBuilder->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id'); |
||
108 | $queryBuilder->innerJoin('b.nodeVersions', 'nv', 'WITH', 'b.publicNodeVersion = nv.id'); |
||
109 | $queryBuilder->andWhere('b.lang = :lang'); |
||
110 | $queryBuilder->andWhere('n.deleted = 0'); |
||
111 | $queryBuilder->andWhere('n.refEntityName = :class'); |
||
112 | $queryBuilder->addOrderBy('b.updated', 'DESC'); |
||
113 | $queryBuilder->setParameter('lang', $this->locale); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param mixed $item |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | View Code Duplication | public function getEditUrlFor($item) |
|
122 | { |
||
123 | /* @var Node $node */ |
||
124 | $node = $item->getNode(); |
||
125 | |||
126 | return array( |
||
127 | 'path' => 'KunstmaanNodeBundle_nodes_edit', |
||
128 | 'params' => array('id' => $node->getId()), |
||
129 | ); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Get the delete url for the given $item |
||
134 | * |
||
135 | * @param object $item |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | public function getDeleteUrlFor($item) |
||
140 | { |
||
141 | /* @var Node $node */ |
||
142 | $node = $item->getNode(); |
||
143 | |||
144 | return array( |
||
145 | 'path' => 'KunstmaanNodeBundle_nodes_delete', |
||
146 | 'params' => array('id' => $node->getId()), |
||
147 | ); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * Returns the OverviewPage of these articles |
||
152 | * |
||
153 | * @return AbstractArticleOverviewPage |
||
154 | */ |
||
155 | public function getOverviewPage() |
||
156 | { |
||
157 | $repository = $this->getOverviewPageRepository(); |
||
158 | $pages = $repository->findActiveOverviewPages(); |
||
159 | |||
160 | if (isset($pages) && count($pages) > 0) { |
||
161 | return $pages[0]; |
||
162 | } |
||
163 | |||
164 | return null; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Returns all overview pages |
||
169 | * |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public function getOverviewPages() |
||
173 | { |
||
174 | return $this->getOverviewPageRepository()->findActiveOverviewPages(); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getListTemplate() |
||
181 | { |
||
182 | return 'KunstmaanArticleBundle:AbstractArticlePageAdminList:list.html.twig'; |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * Returns the full entity class name |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | public function getEntityClassName() |
||
191 | { |
||
192 | return $this->em->getRepository($this->getRepositoryName())->getClassName(); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @return \Doctrine\ORM\EntityRepository |
||
197 | */ |
||
198 | abstract public function getOverviewPageRepository(); |
||
199 | } |
||
200 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: