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

AbstractDashboardBlock::setTemplating()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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\DependencyInjection\ContainerInterface;
15
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
16
use Symfony\Bundle\TwigBundle\TwigEngine;
17
18
abstract class AbstractDashboardBlock implements ContainerAwareInterface
19
{
20
    /**
21
     * @var TwigEngine
22
     */
23
    private $templating;
24
25
    /**
26
     * @var ContainerInterface
27
     */
28
    private $container;
29
30
    /**
31
     * @var string
32
     */
33
    protected $template;
34
35
    /**
36
     * @var array
37
     */
38
    protected $templateParameters = [];
39
40
    /**
41
     * handleParameters should handle $templateParameters. It will be called when
42
     * the block template will be rendered. Please override this method to set
43
     * the view parameters of your block.
44
     */
45
    public function handleParameters()
46
    {
47
        $this->templateParameters = [];
48
    }
49
50
    /**
51
     * @param string $template
52
     */
53
    public function __construct($template = null)
54
    {
55
        $this->template = $template;
56
    }
57
58
    /**
59
     * @return string The content of rendered template
60
     */
61
    public function render()
62
    {
63
        $this->handleParameters();
64
65
        return $this->templating->render($this->template, $this->templateParameters);
66
    }
67
68
    /**
69
     * @return TwigEngine
70
     */
71
    public function getTemplating()
72
    {
73
        return $this->templating;
74
    }
75
76
    /**
77
     * @param TwigEngine templating
78
     *
79
     * @return self
80
     */
81
    public function setTemplating(TwigEngine $templating)
82
    {
83
        $this->templating = $templating;
84
85
        return $this;
86
    }
87
88
    /**
89
     * @return ContainerInterface
90
     */
91
    public function getContainer()
92
    {
93
        return $this->container;
94
    }
95
96
    /**
97
     * @param ContainerInterface container
98
     *
99
     * @return self
100
     */
101
    public function setContainer(ContainerInterface $container = null)
102
    {
103
        $this->container = $container;
104
105
        return $this;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getTemplate()
112
    {
113
        return $this->template;
114
    }
115
116
    /**
117
     * @param string template
118
     *
119
     * @return self
120
     */
121
    public function setTemplate($template)
122
    {
123
        $this->template = $template;
124
125
        return $this;
126
    }
127
128
    /**
129
     * @return string
130
     */
131
    public function getTemplateParameters()
132
    {
133
        return $this->templateParameters;
134
    }
135
136
    /**
137
     * @param string templateParameters
138
     *
139
     * @return self
140
     */
141
    public function setTemplateParameters($templateParameters)
142
    {
143
        $this->templateParameters = $templateParameters;
144
145
        return $this;
146
    }
147
}
148