1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the adminbsb-material-design-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 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\AdminBSBBundle\Twig\Extension\Form; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\AdminBSBBundle\Twig\Extension\AbstractTwigExtension; |
15
|
|
|
use WBW\Library\Core\Argument\Helper\StringHelper; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Abstract radio button Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Form |
22
|
|
|
* @abstract |
23
|
|
|
*/ |
24
|
|
|
abstract class AbstractRadioButtonTwigExtension extends AbstractTwigExtension { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Displays a AdminBSB radio button. |
28
|
|
|
* |
29
|
|
|
* @param string|null $content The content. |
30
|
|
|
* @param string|null $name The name. |
31
|
|
|
* @param string|null $id The id. |
32
|
|
|
* @param bool $checked Checked ? |
33
|
|
|
* @param bool $disabled Disabled ? |
34
|
|
|
* @param bool $withGap With gap ? |
35
|
|
|
* @param string|null $class The class. |
36
|
|
|
* @return string Returns the AdminBSB radio button. |
37
|
|
|
*/ |
38
|
|
|
protected function adminBSBRadioButton(?string $content, ?string $name, ?string $id, bool $checked, bool $disabled, bool $withGap, ?string $class): string { |
39
|
|
|
|
40
|
|
|
$template = "<input %attributes%>%innerHTML%"; |
41
|
|
|
|
42
|
|
|
$attributes = []; |
43
|
|
|
|
44
|
|
|
$attributes["class"] = [true === $withGap ? "with-gap" : null, $class]; |
45
|
|
|
$attributes["name"] = $name; |
46
|
|
|
$attributes["type"] = "radio"; |
47
|
|
|
$attributes["id"] = $id; |
48
|
|
|
$attributes["checked"] = true === $checked ? "checked" : null; |
49
|
|
|
$attributes["disabled"] = true === $disabled ? "disabled" : null; |
50
|
|
|
|
51
|
|
|
$innerHTML = static::coreHTMLElement("label", $content, ["for" => $attributes["id"]]); |
52
|
|
|
|
53
|
|
|
return str_replace(["%attributes%", "%innerHTML%"], [StringHelper::parseArray($attributes), $innerHTML], $template); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|