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 Symfony\Component\Routing\Annotation\Route;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10
use Symfony\Component\HttpFoundation\Request;
11
12
class TagAdminListController extends AdminListController
13
{
14
    /**
15
     * @var AdminListConfiguratorInterface
16
     */
17
    private $configurator;
18
19
    /**
20
     * @return AdminListConfiguratorInterface
21
     */
22
    public function getAdminListConfigurator()
23
    {
24
        if (!isset($this->configurator)) {
25
            $this->configurator = new TagAdminListConfigurator($this->getEntityManager());
26
        }
27
28
        return $this->configurator;
29
    }
30
31
    /**
32
     * @Route("/", name="kunstmaantaggingbundle_admin_tag")
33
     * @Template("KunstmaanAdminListBundle:Default:list.html.twig")
34
     */
35
    public function indexAction(Request $request)
36
    {
37
        return parent::doIndexAction($this->getAdminListConfigurator(), $request);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (doIndexAction() instead of indexAction()). Are you sure this is correct? If so, you might want to change this to $this->doIndexAction().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

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