Passed
Push — master ( cbbc27...86f200 )
by Dev
11:12
created

PageAdminController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 29
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A listAction() 0 13 3
A treeAction() 0 12 1
1
<?php
2
3
namespace PiedWeb\CMSBundle\Controller;
4
5
use Sonata\AdminBundle\Controller\CRUDController;
6
7
class PageAdminController extends CRUDController
8
{
9
    public function listAction()
10
    {
11
        $request = $this->getRequest();
12
        if ($listMode = $request->get('_list_mode')) {
13
            $this->admin->setListMode($listMode);
14
        }
15
16
        $listMode = $this->admin->getListMode();
17
        if ('tree' === $listMode) {
18
            return $this->treeAction();
19
        }
20
21
        return parent::listAction();
22
    }
23
24
    public function treeAction()
25
    {
26
        $pages = $this->getDoctrine()
27
            ->getRepository($this->container->getParameter('app.entity_page'))
1 ignored issue
show
Bug introduced by
The method getParameter() does not exist on Psr\Container\ContainerInterface. It seems like you code against a sub-type of Psr\Container\ContainerInterface such as Symfony\Component\Depend...tion\ContainerInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
            ->getRepository($this->container->/** @scrutinizer ignore-call */ getParameter('app.entity_page'))
Loading history...
28
            ->getPagesWithoutParent();
29
30
        return $this->render('@PiedWebCMS/admin/treeView.html.twig', [
0 ignored issues
show
Deprecated Code introduced by
The function Sonata\AdminBundle\Contr...RUDController::render() has been deprecated: since version 3.27, to be removed in 4.0. Use Sonata\AdminBundle\Controller\CRUDController::renderWithExtraParams() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

30
        return /** @scrutinizer ignore-deprecated */ $this->render('@PiedWebCMS/admin/treeView.html.twig', [

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
31
            'pages' => $pages,
32
            'list' => $this->admin->getList(),
33
            'admin' => $this->admin,
34
            'base_template' => $this->getBaseTemplate(),
35
            'action' => 'list',
36
        ]);
37
    }
38
}
39