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
|
|
|
|