Completed
Push — wip-subtree ( 04b705...405079 )
by
unknown
12:15
created

BaseController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 22 2
1
<?php
2
3
/*
4
 * This file is part of the Blast Project package.
5
 *
6
 * Copyright (C) 2015-2017 Libre Informatique
7
 *
8
 * This file is licenced under the GNU LGPL v3.
9
 * For the full copyright and license information, please view the LICENSE.md
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Blast\Bundle\CoreBundle\Controller;
14
15
use Sonata\AdminBundle\Controller\CoreController as BaseCoreController;
16
use Symfony\Component\HttpFoundation\Response;
17
18
/**
19
 * Class BaseController.
20
 *
21
 * Extends this controller if you want to render a custom view withing sonata'as admin layout.
22
 * Your view has to extends the sonata's admin layout (or overrided layouts)
23
 */
24
class BaseController extends BaseCoreController
25
{
26
    /**
27
     * render.
28
     *
29
     *  ** Overrided to add default sonata's twig parameters
30
     *
31
     * @param string        $view
32
     * @param array         $parameters
33
     * @param Response|null $response
34
     *
35
     * @return Response
36
     */
37
    public function render($view, array $parameters = array(), Response $response = null)
38
    {
39
        $blocks = array(
40
            'top'    => array(),
41
            'left'   => array(),
42
            'center' => array(),
43
            'right'  => array(),
44
            'bottom' => array(),
45
        );
46
47
        foreach ($this->container->getParameter('sonata.admin.configuration.dashboard_blocks') as $block) {
48
            $blocks[$block['position']][] = $block;
49
        }
50
51
        $completeParameters = [
52
            'base_template' => $this->getBaseTemplate(),
53
            'admin_pool'    => $this->container->get('sonata.admin.pool'),
54
            'blocks'        => $blocks,
55
        ];
56
57
        return parent::render($view, array_merge($parameters, $completeParameters), $response); // TODO: Change the autogenerated stub
58
    }
59
}
60