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\TaggingBundle\Controller; |
||
4 | |||
5 | use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface; |
||
6 | use Kunstmaan\AdminListBundle\Controller\AdminListController; |
||
7 | use Kunstmaan\TaggingBundle\AdminList\TagAdminListConfigurator; |
||
8 | use Kunstmaan\TaggingBundle\Entity\Tag; |
||
9 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
||
10 | use Symfony\Component\HttpFoundation\Request; |
||
11 | use Symfony\Component\Routing\Annotation\Route; |
||
12 | |||
13 | class TagAdminListController extends AdminListController |
||
14 | { |
||
15 | /** |
||
16 | * @var AdminListConfiguratorInterface |
||
17 | */ |
||
18 | private $configurator; |
||
19 | |||
20 | /** |
||
21 | * @return AdminListConfiguratorInterface |
||
22 | */ |
||
23 | public function getAdminListConfigurator() |
||
24 | { |
||
25 | if (!isset($this->configurator)) { |
||
26 | $this->configurator = new TagAdminListConfigurator($this->getEntityManager()); |
||
27 | } |
||
28 | |||
29 | return $this->configurator; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @Route("/", name="kunstmaantaggingbundle_admin_tag") |
||
34 | * @Template("@KunstmaanAdminList/Default/list.html.twig") |
||
35 | */ |
||
36 | public function indexAction(Request $request) |
||
37 | { |
||
38 | return parent::doIndexAction($this->getAdminListConfigurator(), $request); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @Route("/add", name="kunstmaantaggingbundle_admin_tag_add", methods={"GET", "POST"}) |
||
43 | * @Template("@KunstmaanAdminList/Default/add.html.twig") |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function addAction(Request $request) |
||
48 | { |
||
49 | return parent::doAddAction($this->getAdminListConfigurator(), null, $request); |
||
0 ignored issues
–
show
|
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @Route("/{id}/edit", requirements={"id" = "\d+"}, name="kunstmaantaggingbundle_admin_tag_edit", methods={"GET", "POST"}) |
||
54 | * @Template("@KunstmaanAdminList/Default/edit.html.twig") |
||
55 | */ |
||
56 | public function editAction(Request $request, $id) |
||
57 | { |
||
58 | return parent::doEditAction($this->getAdminListConfigurator(), $id, $request); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @Route("/{id}/delete", requirements={"id" = "\d+"}, name="kunstmaantaggingbundle_admin_tag_delete", methods={"GET", "POST"}) |
||
63 | * @Template("@KunstmaanAdminList/Default/delete.html.twig") |
||
64 | */ |
||
65 | public function deleteAction(Request $request, $id) |
||
66 | { |
||
67 | return parent::doDeleteAction($this->getAdminListConfigurator(), $id, $request); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @Route("/autocomplete.{_format}", name="kunstmaantaggingbundle_admin_tag_autocomplete", defaults={"_format" = "json"}) |
||
72 | * @Template("@KunstmaanTagging/Tags/autocomplete.json.twig") |
||
73 | * |
||
74 | * @return array |
||
75 | */ |
||
76 | public function autocompleteAction(Request $request) |
||
77 | { |
||
78 | $search = $request->get('term'); |
||
79 | $em = $this->getDoctrine()->getManager(); |
||
80 | $qb = $em->getRepository(Tag::class)->createQueryBuilder('n') |
||
81 | ->where('n.name LIKE :search') |
||
82 | ->orderBy('n.name', 'ASC') |
||
83 | ->setParameter('search', '%' . $search . '%'); |
||
84 | $tags = $qb->getQuery()->getResult(); |
||
85 | |||
86 | return ['tags' => $tags]; |
||
87 | } |
||
88 | } |
||
89 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.