Completed
Push — master ( 6c15b7...f5f8be )
by Sander
12:00
created

Controller/TagAdminListController.php (1 issue)

Upgrade to new PHP Analysis Engine

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 Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
11
use Symfony\Component\HttpFoundation\Request;
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("KunstmaanAdminListBundle:Default:list.html.twig")
35
     */
36
    public function indexAction(Request $request)
37
    {
38
        return parent::doIndexAction($this->getAdminListConfigurator(), $request);
0 ignored issues
show
$this->getAdminListConfigurator() of type object<Kunstmaan\AdminLi...tConfiguratorInterface> is not a sub-type of object<Kunstmaan\AdminLi...tAdminListConfigurator>. It seems like you assume a concrete implementation of the interface Kunstmaan\AdminListBundl...stConfiguratorInterface to be always present.

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.

Loading history...
39
    }
40
41
    /**
42
     * @Route("/add", name="kunstmaantaggingbundle_admin_tag_add")
43
     * @Method({"GET", "POST"})
44
     * @Template("KunstmaanAdminListBundle:Default:add.html.twig")
45
     *
46
     * @return array
47
     */
48
    public function addAction(Request $request)
49
    {
50
        return parent::doAddAction($this->getAdminListConfigurator(), null, $request);
51
    }
52
53
    /**
54
     * @Route("/{id}/edit", requirements={"id" = "\d+"}, name="kunstmaantaggingbundle_admin_tag_edit")
55
     * @Method({"GET", "POST"})
56
     * @Template("KunstmaanAdminListBundle:Default:edit.html.twig")
57
     */
58
    public function editAction(Request $request, $id)
59
    {
60
        return parent::doEditAction($this->getAdminListConfigurator(), $id, $request);
61
    }
62
63
    /**
64
     * @Route("/{id}/delete", requirements={"id" = "\d+"}, name="kunstmaantaggingbundle_admin_tag_delete")
65
     * @Method({"GET", "POST"})
66
     * @Template("KunstmaanAdminListBundle:Default:delete.html.twig")
67
     */
68
    public function deleteAction(Request $request, $id)
69
    {
70
        return parent::doDeleteAction($this->getAdminListConfigurator(), $id, $request);
71
    }
72
73
    /**
74
     * @Route("/autocomplete.{_format}", name="kunstmaantaggingbundle_admin_tag_autocomplete", defaults={"_format" = "json"})
75
     * @Template()
76
     *
77
     * @param \Symfony\Component\HttpFoundation\Request $request
78
     *
79
     * @return array
80
     */
81
    public function autocompleteAction(Request $request)
82
    {
83
        $search = $request->get('term');
84
        $em = $this->getDoctrine()->getManager();
85
        $qb = $em->getRepository('KunstmaanTaggingBundle:Tag')->createQueryBuilder('n')
86
            ->where('n.name LIKE :search')
87
            ->orderBy('n.name', 'ASC')
88
            ->setParameter('search', '%' . $search . '%');
89
        $tags = $qb->getQuery()->getResult();
90
91
        return array('tags' => $tags);
92
    }
93
}
94