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

Controller/PopupsAdminListController.php (3 issues)

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\LeadGenerationBundle\Controller;
4
5
use Kunstmaan\AdminBundle\Entity\EntityInterface;
6
use Kunstmaan\AdminListBundle\AdminList\Configurator\AdminListConfiguratorInterface;
7
use Kunstmaan\AdminListBundle\AdminList\ItemAction\SimpleItemAction;
8
use Kunstmaan\AdminListBundle\Controller\AdminListController;
9
use Kunstmaan\LeadGenerationBundle\AdminList\PopupAdminListConfigurator;
10
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
11
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12
use Symfony\Component\HttpFoundation\Request;
13
14
class PopupsAdminListController extends AdminListController
15
{
16
    /**
17
     * @var AdminListConfiguratorInterface
18
     */
19
    private $configurator;
20
21
    /**
22
     * @return AdminListConfiguratorInterface
23
     */
24
    public function getAdminListConfigurator($listAction = false)
25
    {
26
        if (!isset($this->configurator)) {
27
            $this->configurator = new PopupAdminListConfigurator($this->getEntityManager());
28
29
            if ($listAction) {
30
                $create_route = function (EntityInterface $item) {
31
                    return array(
32
                        'path' => 'kunstmaanleadgenerationbundle_admin_rule_abstractrule_detail',
33
                        'params' => array('popup' => $item->getId()),
34
                    );
35
                };
36
                $this->configurator->addItemAction(new SimpleItemAction($create_route, 'th-list', 'Manage rules'));
37
            }
38
        }
39
40
        return $this->configurator;
41
    }
42
43
    /**
44
     * The index action
45
     *
46
     * @Route("/", name="kunstmaanleadgenerationbundle_admin_popup_abstractpopup")
47
     */
48
    public function indexAction(Request $request)
49
    {
50
        return parent::doIndexAction($this->getAdminListConfigurator(true), $request);
51
    }
52
53
    /**
54
     * The delete action
55
     *
56
     * @param int $id
57
     *
58
     * @Route("/{id}/delete", requirements={"id" = "\d+"}, name="kunstmaanleadgenerationbundle_admin_popup_abstractpopup_delete")
59
     * @Method({"GET", "POST"})
60
     *
61
     * @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...
62
     */
63
    public function deleteAction(Request $request, $id)
64
    {
65
        return parent::doDeleteAction($this->getAdminListConfigurator(), $id, $request);
66
    }
67
68
    /**
69
     * The edit action
70
     *
71
     * @param int $id
72
     *
73
     * @Route("/{id}/edit", requirements={"id" = "\d+"}, name="kunstmaanleadgenerationbundle_admin_popup_abstractpopup_edit")
74
     * @Method({"GET", "POST"})
75
     *
76
     * @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...
77
     */
78
    public function editAction(Request $request, $id)
79
    {
80
        return parent::doEditAction($this->getAdminListConfigurator(), $id, $request);
81
    }
82
83
    /**
84
     * The add action
85
     *
86
     * @Route("/add",  name="kunstmaanleadgenerationbundle_admin_popup_abstractpopup_add")
87
     * @Method({"GET", "POST"})
88
     *
89
     * @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...
90
     */
91
    public function addAction(Request $request)
92
    {
93
        $type = $request->get('type');
94
95
        return parent::doAddAction($this->getAdminListConfigurator(), $type, $request);
96
    }
97
}
98