Completed
Pull Request — 5.6 (#2830)
by Jeroen
14:14
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\HttpFoundation\Request;
11
use Symfony\Component\Routing\Annotation\Route;
12
13
class MenuAdminListController extends AdminListController
14
{
15
    /**
16
     * @var AdminListConfiguratorInterface
17
     */
18
    private $configurator;
19
20
    /**
21
     * @return AbstractAdminListConfigurator
22
     */
23
    public function getAdminListConfigurator(Request $request)
24
    {
25
        if (!isset($this->configurator)) {
26
            $configuratorClass = $this->container->getParameter('kunstmaan_menu.adminlist.menu_configurator.class');
27
            $this->configurator = new $configuratorClass(
28
                $this->getEntityManager()
29
            );
30
31
            $create_route = function (EntityInterface $item) {
32
                return [
33
                    'path' => 'kunstmaanmenubundle_admin_menuitem',
34
                    'params' => ['menuid' => $item->getId()],
35
                ];
36
            };
37
            $this->configurator->addItemAction(
38
                new SimpleItemAction($create_route, 'th-list', 'kuma_menu.menu.adminlist.action.manage')
39
            );
40
            $this->configurator->setLocale($request->getLocale());
41
        }
42
43
        return $this->configurator;
44
    }
45
46
    /**
47
     * @Route("/", name="kunstmaanmenubundle_admin_menu")
48
     *
49
     * @return array
0 ignored issues
show
Should the return type not be \Symfony\Component\HttpFoundation\Response?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51
    public function indexAction(Request $request)
52
    {
53
        // Make sure we have a menu for each possible locale
54
        $this->container->get('kunstmaan_menu.menu.service')->makeSureMenusExist();
55
56
        return parent::doIndexAction(
57
            $this->getAdminListConfigurator($request),
58
            $request
59
        );
60
    }
61
}
62