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

DashboardSonataBlock   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 1
cbo 4
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureSettings() 0 8 1
A execute() 0 10 2
A setRegistry() 0 6 1
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\Dashboard;
13
14
use Symfony\Component\OptionsResolver\OptionsResolver;
15
use Symfony\Component\HttpFoundation\Response;
16
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
17
use Sonata\BlockBundle\Block\BlockContextInterface;
18
19
class DashboardSonataBlock extends AbstractBlockService
20
{
21
    /**
22
     * @var DashboardBlockRegistry
23
     */
24
    private $registry;
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function configureSettings(OptionsResolver $resolver)
30
    {
31
        $resolver->setDefaults(array(
32
            'url'      => false,
33
            'title'    => 'blast.label.dashboard_block_title',
34
            'template' => 'BlastCoreBundle:Dashboard:mainDashboard.html.twig',
35
        ));
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function execute(BlockContextInterface $blockContext, Response $response = null)
42
    {
43
        $dashboardBlocks = $this->registry->getRegistredBlocks();
44
45
        return $this->renderResponse($blockContext->getTemplate(), array(
46
            'block_context'    => $blockContext,
47
            'block'            => $blockContext->getBlock(),
48
            'dashboard_blocks' => $dashboardBlocks ?: [],
49
        ), $response);
50
    }
51
52
    /**
53
     * @param DashboardBlockRegistry registry
54
     *
55
     * @return self
56
     */
57
    public function setRegistry(DashboardBlockRegistry $registry)
58
    {
59
        $this->registry = $registry;
60
61
        return $this;
62
    }
63
}
64