1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Khusseini\PimcoreRadBrickBundle\Areabricks; |
4
|
|
|
|
5
|
|
|
use Khusseini\PimcoreRadBrickBundle\AreabrickRenderer; |
6
|
|
|
use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick; |
7
|
|
|
use Pimcore\Model\Document\Tag\Area\Info; |
8
|
|
|
use Symfony\Component\HttpFoundation\Response; |
9
|
|
|
|
10
|
|
|
abstract class AbstractAreabrick extends AbstractTemplateAreabrick |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $name; |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private $icon; |
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private $label; |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $openTag = ''; |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $closeTag = ''; |
32
|
|
|
/** |
33
|
|
|
* @var bool |
34
|
|
|
*/ |
35
|
|
|
private $useEdit = false; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var AreabrickRenderer |
39
|
|
|
*/ |
40
|
|
|
private $areabrickRenderer; |
41
|
|
|
|
42
|
2 |
|
public function __construct( |
43
|
|
|
string $name, |
44
|
|
|
AreabrickRenderer $areabrickRenderer |
45
|
|
|
) { |
46
|
2 |
|
$this->name = $name; |
47
|
2 |
|
$this->areabrickRenderer = $areabrickRenderer; |
48
|
2 |
|
$options = $areabrickRenderer->getAreabrickConfig($name); |
49
|
2 |
|
$this->icon = $options['icon']; |
50
|
2 |
|
$this->label = $options['label']; |
51
|
2 |
|
$this->openTag = $options['open']; |
52
|
2 |
|
$this->closeTag = $options['close']; |
53
|
2 |
|
$this->useEdit = $options['use_edit']; |
54
|
2 |
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
* @codeCoverageIgnore |
59
|
|
|
*/ |
60
|
|
|
public function getIcon() |
61
|
|
|
{ |
62
|
|
|
return $this->icon ?: parent::getIcon(); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
* @codeCoverageIgnore |
68
|
|
|
*/ |
69
|
|
|
public function getName() |
70
|
|
|
{ |
71
|
|
|
return $this->label ?: parent::getName(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return bool |
76
|
|
|
* @codeCoverageIgnore |
77
|
|
|
*/ |
78
|
|
|
public function hasEditTemplate() |
79
|
|
|
{ |
80
|
|
|
return $this->useEdit; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* {@inheritdoc} |
85
|
|
|
* |
86
|
|
|
* @codeCoverageIgnore |
87
|
|
|
*/ |
88
|
|
|
public function getTemplateLocation() |
89
|
|
|
{ |
90
|
|
|
return static::TEMPLATE_LOCATION_GLOBAL; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
* |
96
|
|
|
* @codeCoverageIgnore |
97
|
|
|
*/ |
98
|
|
|
public function getTemplateSuffix() |
99
|
|
|
{ |
100
|
|
|
return static::TEMPLATE_SUFFIX_TWIG; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return Response|null |
105
|
|
|
*/ |
106
|
1 |
|
public function action(Info $info) |
107
|
|
|
{ |
108
|
1 |
|
$this->areabrickRenderer->render($this->name, $info); |
109
|
|
|
|
110
|
1 |
|
return $this->doAction($info); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
1 |
|
public function doAction(Info $info): ?Response |
|
|
|
|
114
|
|
|
{ |
115
|
1 |
|
return null; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @codeCoverageIgnore |
120
|
|
|
* |
121
|
|
|
* @param array<string, mixed> $options |
122
|
|
|
*/ |
123
|
|
|
public function configure(array $options): void |
|
|
|
|
124
|
|
|
{ |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* {@inheritdoc} |
129
|
|
|
* |
130
|
|
|
* @codeCoverageIgnore |
131
|
|
|
*/ |
132
|
|
|
public function postRenderAction(Info $info) |
133
|
|
|
{ |
134
|
|
|
return null; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* {@inheritdoc} |
139
|
|
|
* |
140
|
|
|
* @codeCoverageIgnore |
141
|
|
|
*/ |
142
|
|
|
public function getHtmlTagOpen(Info $info) |
143
|
|
|
{ |
144
|
|
|
return $this->openTag; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* {@inheritdoc} |
149
|
|
|
* |
150
|
|
|
* @codeCoverageIgnore |
151
|
|
|
*/ |
152
|
|
|
public function getHtmlTagClose(Info $info) |
153
|
|
|
{ |
154
|
|
|
return $this->closeTag; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.