Total Complexity | 6 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | trait HasButtonRendererTrait |
||
13 | { |
||
14 | protected $buttonsRenderer = []; |
||
15 | |||
16 | /** |
||
17 | * @return string |
||
18 | */ |
||
19 | public function renderButtons() |
||
20 | { |
||
21 | $return = ''; |
||
22 | $buttons = $this->getForm()->getButtons(); |
||
|
|||
23 | if ($buttons) { |
||
24 | $return .= '<div class="form-actions">'; |
||
25 | foreach ($buttons as $button) { |
||
26 | $return .= $button->render() . "\n"; |
||
27 | } |
||
28 | $return .= ' <div class="clear"></div>'; |
||
29 | $return .= '</div>'; |
||
30 | } |
||
31 | |||
32 | return $return; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param AbstractButton $button |
||
37 | * @return mixed |
||
38 | */ |
||
39 | public function getButtonRenderer(AbstractButton $button) |
||
40 | { |
||
41 | $name = $button->getName(); |
||
42 | if (!isset($this->buttonsRenderer[$name])) { |
||
43 | $this->buttonsRenderer[$name] = $this->getNewButtonRenderer($button); |
||
44 | } |
||
45 | |||
46 | return $this->buttonsRenderer[$name]; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param AbstractButton $button |
||
51 | * @return mixed |
||
52 | */ |
||
53 | protected function getNewButtonRenderer(AbstractButton $button) |
||
63 | } |
||
64 | } |
||
65 |