DashboardSonataBlock   A
last analyzed

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