Passed
Push — master ( 97dd58...4109cd )
by Dev
10:22
created

PageAdminCRUDController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 29
rs 10
c 0
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\Admin;
4
5
use Sonata\AdminBundle\Controller\CRUDController;
6
7
class PageAdminCRUDController 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('pwc.entity_page'))
28
            ->getPagesWithoutParent();
29
30
        return $this->renderWithExtraParams('@PiedWebCMS/admin/page_treeView.html.twig', [
31
            'pages' => $pages,
32
            'list' => $this->admin->getList(),
33
            'admin' => $this->admin,
34
            'base_template' => $this->getBaseTemplate(),
35
            'action' => 'list',
36
        ]);
37
    }
38
}
39