Total Complexity | 10 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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) |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @return Nip_Form_Renderer_DisplayGroup|null |
||
22 | */ |
||
23 | public function getGroup() |
||
26 | } |
||
27 | |||
28 | public function render() |
||
29 | { |
||
30 | $return = '<fieldset' . $this->renderAttributes() . '>'; |
||
31 | $return .= '<legend>' . $this->getGroup()->getLegend() . '</legend>'; |
||
32 | |||
33 | if (count($this->getGroup())) { |
||
34 | $renderer = clone $this->getGroup()->getForm()->getRenderer(); |
||
35 | $renderer->setElements($this->getGroup()->toArray()); |
||
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(); |
||
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() |
||
61 | } |
||
62 | } |
||
63 |