|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the bootstrap-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2019 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Button; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Button renderer. |
|
16
|
|
|
* |
|
17
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
18
|
|
|
* @package WBW\Bundle\BootstrapBundle\Button |
|
19
|
|
|
*/ |
|
20
|
|
|
class ButtonRenderer { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Render an active. |
|
24
|
|
|
* |
|
25
|
|
|
* @param ButtonInterface $button The button. |
|
26
|
|
|
* @return string|null Returns the rendered active. |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function renderActive(ButtonInterface $button) { |
|
29
|
|
|
return true === $button->getActive() ? "active" : null; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Render a block. |
|
34
|
|
|
* |
|
35
|
|
|
* @param ButtonInterface $button The button. |
|
36
|
|
|
* @return string|null Returns the rendered block. |
|
37
|
|
|
*/ |
|
38
|
|
|
public static function renderBlock(ButtonInterface $button) { |
|
39
|
|
|
return true === $button->getBlock() ? "btn-block" : null; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Render a content. |
|
44
|
|
|
* |
|
45
|
|
|
* @param ButtonInterface $button The button. |
|
46
|
|
|
* @return string|null Returns the rendered block. |
|
47
|
|
|
*/ |
|
48
|
|
|
public static function renderContent(ButtonInterface $button) { |
|
49
|
|
|
return null !== $button->getContent() ? $button->getContent() : ""; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Render a data placement. |
|
54
|
|
|
* |
|
55
|
|
|
* @param ButtonInterface $button The button. |
|
56
|
|
|
* @return string|null Returns the rendered data placement. |
|
57
|
|
|
*/ |
|
58
|
|
|
public static function renderDataPlacement(ButtonInterface $button) { |
|
59
|
|
|
return null !== $button->getTitle() ? "top" : null; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Render a data toggle. |
|
64
|
|
|
* |
|
65
|
|
|
* @param ButtonInterface $button The button. |
|
66
|
|
|
* @return string|null Returns the rendered data toggle. |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function renderDataToggle(ButtonInterface $button) { |
|
69
|
|
|
return null !== $button->getTitle() ? "tooltip" : null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Render a disabled. |
|
74
|
|
|
* |
|
75
|
|
|
* @param ButtonInterface $button The button. |
|
76
|
|
|
* @return string|null Returns the rendered disabled. |
|
77
|
|
|
*/ |
|
78
|
|
|
public static function renderDisabled(ButtonInterface $button) { |
|
79
|
|
|
return true === $button->getDisabled() ? "disabled" : null; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Render a size. |
|
84
|
|
|
* |
|
85
|
|
|
* @param ButtonInterface $button The button. |
|
86
|
|
|
* @return string|null Returns the rendered size. |
|
87
|
|
|
*/ |
|
88
|
|
|
public static function renderSize(ButtonInterface $button) { |
|
89
|
|
|
return null !== $button->getSize() ? "btn-" . $button->getSize() : null; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Render a title. |
|
94
|
|
|
* |
|
95
|
|
|
* @param ButtonInterface $button The button. |
|
96
|
|
|
* @return string Returns the rendered title. |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function renderTitle(ButtonInterface $button) { |
|
99
|
|
|
return $button->getTitle(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Render a type. |
|
104
|
|
|
* |
|
105
|
|
|
* @param ButtonInterface $button The button. |
|
106
|
|
|
* @return string Returns the rendered title. |
|
107
|
|
|
*/ |
|
108
|
|
|
public static function renderType(ButtonInterface $button) { |
|
109
|
|
|
return null !== $button->getType() ? "btn-" . $button->getType() : null; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|