Completed
Push — wip-platform ( 03cba6...2999ab )
by
unknown
05:53 queued 02:49
created

BaseController::render()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

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