1 | <?php |
||||
2 | |||||
3 | class Nip_Form_Renderer_DisplayGroup |
||||
4 | { |
||||
5 | /** |
||||
6 | * @var Nip_Form_DisplayGroup |
||||
7 | */ |
||||
8 | protected $_group; |
||||
9 | |||||
10 | |||||
11 | /** |
||||
12 | * @return Nip_Form_Renderer_DisplayGroup |
||||
13 | */ |
||||
14 | public function setGroup(Nip_Form_DisplayGroup $group) |
||||
15 | { |
||||
16 | $this->_group = $group; |
||||
17 | return $this; |
||||
18 | } |
||||
19 | |||||
20 | /** |
||||
21 | * @return Nip_Form_Renderer_DisplayGroup|null |
||||
22 | */ |
||||
23 | public function getGroup() |
||||
24 | { |
||||
25 | return $this->_group; |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||||
26 | } |
||||
27 | |||||
28 | public function render() |
||||
29 | { |
||||
30 | $return = '<fieldset' . $this->renderAttributes() . '>'; |
||||
31 | $return .= '<legend>' . $this->getGroup()->getLegend() . '</legend>'; |
||||
0 ignored issues
–
show
The method
getLegend() does not exist on Nip_Form_Renderer_DisplayGroup .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
32 | |||||
33 | if (count($this->getGroup())) { |
||||
0 ignored issues
–
show
$this->getGroup() of type Nip_Form_Renderer_DisplayGroup|null is incompatible with the type Countable|array expected by parameter $value of count() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
34 | $renderer = clone $this->getGroup()->getForm()->getRenderer(); |
||||
0 ignored issues
–
show
The method
getForm() does not exist on Nip_Form_Renderer_DisplayGroup .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
35 | $renderer->setElements($this->getGroup()->toArray()); |
||||
0 ignored issues
–
show
The method
toArray() does not exist on Nip_Form_Renderer_DisplayGroup .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
36 | $return .= $renderer->renderElements(); |
||||
37 | } |
||||
38 | $return .= '</fieldset>'; |
||||
39 | return $return; |
||||
40 | } |
||||
41 | |||||
42 | public function renderAttributes($overrides = array()) |
||||
43 | { |
||||
44 | $attribs = $this->getGroup()->getAttribs(); |
||||
0 ignored issues
–
show
The method
getAttribs() does not exist on Nip_Form_Renderer_DisplayGroup .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
45 | $elementAttribs = $this->getElementAttribs(); |
||||
46 | $return = ''; |
||||
47 | foreach ($attribs as $name => $value) { |
||||
48 | if (strpos($name, 'data-') === 0 || in_array($name, $elementAttribs)) { |
||||
49 | if (in_array($name, array_keys($overrides))) { |
||||
50 | $value = $overrides[$name]; |
||||
51 | } |
||||
52 | $return .= ' ' . $name . '="' . $value . '"'; |
||||
53 | } |
||||
54 | } |
||||
55 | return $return; |
||||
56 | } |
||||
57 | |||||
58 | public function getElementAttribs() |
||||
59 | { |
||||
60 | return ['id', 'style', 'class']; |
||||
61 | } |
||||
62 | } |
||||
63 |