Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

MenuBundle/Controller/MenuAdminListController.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\MenuBundle\Controller;
4
5
use Kunstmaan\AdminBundle\Entity\EntityInterface;
6
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractAdminListConfigurator;
7
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface;
8
use Kunstmaan\AdminListBundle\AdminList\ItemAction\SimpleItemAction;
9
use Kunstmaan\AdminListBundle\Controller\AdminListController;
10
use Symfony\Component\Routing\Annotation\Route;
11
use Symfony\Component\HttpFoundation\Request;
12
13
class MenuAdminListController extends AdminListController
14
{
15
    /**
16
     * @var AdminListConfiguratorInterface
17
     */
18
    private $configurator;
19
20
    /**
21
     * @param Request $request
22
     *
23
     * @return AbstractAdminListConfigurator
24
     */
25
    public function getAdminListConfigurator(Request $request)
26
    {
27
        if (!isset($this->configurator)) {
28
            $configuratorClass = $this->container->getParameter('kunstmaan_menu.adminlist.menu_configurator.class');
29
            $this->configurator = new $configuratorClass(
30
                $this->getEntityManager()
31
            );
32
33
            $create_route = function (EntityInterface $item) {
34
                return array(
35
                    'path' => 'kunstmaanmenubundle_admin_menuitem',
36
                    'params' => array('menuid' => $item->getId()),
37
                );
38
            };
39
            $this->configurator->addItemAction(
40
                new SimpleItemAction($create_route, 'th-list', 'kuma_menu.menu.adminlist.action.manage')
41
            );
42
            $this->configurator->setLocale($request->getLocale());
43
        }
44
45
        return $this->configurator;
46
    }
47
48
    /**
49
     * @Route("/", name="kunstmaanmenubundle_admin_menu")
50
     *
51
     * @param Request $request
52
     *
53
     * @return array
54
     */
55
    public function indexAction(Request $request)
56
    {
57
        // Make sure we have a menu for each possible locale
58
        $this->container->get('kunstmaan_menu.menu.service')->makeSureMenusExist();
59
60
        return parent::doIndexAction(
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...
61
            $this->getAdminListConfigurator($request),
62
            $request
63
        );
64
    }
65
}
66