|
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\AdminBSBMaterialDesignBundle\Twig\Extension\Form; |
|
13
|
|
|
|
|
14
|
|
|
use Twig_SimpleFunction; |
|
15
|
|
|
use WBW\Library\Core\Utility\ArrayUtility; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Radio button form Twig extension. |
|
19
|
|
|
* |
|
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
21
|
|
|
* @package WBW\Bundle\AdminBSBMaterialDesignBundle\Twig\Extension\Form |
|
22
|
|
|
* @final |
|
23
|
|
|
*/ |
|
24
|
|
|
final class RadioButtonFormTwigExtension extends AbstractFormTwigExtension { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Service name. |
|
28
|
|
|
* |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
const SERVICE_NAME = "webeweb.bundle.adminbsbmaterialdesignbundle.twig.extension.form.radiobutton"; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Displays an AdminBSB basic radio button. |
|
35
|
|
|
* |
|
36
|
|
|
* @param array $args The arguments. |
|
37
|
|
|
* @return string Returns the AdminBSB basic radio button. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function absbmdBasicRadioButtonFunction(array $args = []) { |
|
40
|
|
|
return $this->absbmdRadioButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "name"), ArrayUtility::get($args, "id"), ArrayUtility::get($args, "checked", false), ArrayUtility::get($args, "disabled", false), ArrayUtility::get($args, "withGap", false), ArrayUtility::get($args, "class")); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Get the Twig functions. |
|
45
|
|
|
* |
|
46
|
|
|
* @return array Returns the Twig functions. |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getFunctions() { |
|
49
|
|
|
return [ |
|
50
|
|
|
new Twig_SimpleFunction("absbmdBasicRadioButton", [$this, "absbmdBasicRadioButtonFunction"], ["is_safe" => ["html"]]), |
|
51
|
|
|
new Twig_SimpleFunction("absbmdMaterialDesignRadioButton", [$this, "absbmdMaterialDesignRadioButtonFunction"], ["is_safe" => ["html"]]), |
|
52
|
|
|
]; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Displays an AdminBSB material design radio button. |
|
57
|
|
|
* |
|
58
|
|
|
* @param array $args The arguments. |
|
59
|
|
|
* @return string Returns the AdminBSB material design radio button. |
|
60
|
|
|
*/ |
|
61
|
|
|
public function absbmdMaterialDesignRadioButtonFunction(array $args = []) { |
|
62
|
|
|
return $this->absbmdRadioButton(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "name"), ArrayUtility::get($args, "id"), ArrayUtility::get($args, "checked", false), ArrayUtility::get($args, "disabled", false), ArrayUtility::get($args, "withGap", false), ArrayUtility::get($args, "class", "") . $this->getColor(ArrayUtility::get($args, "color", "red"), " radio-col-")); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
} |
|
66
|
|
|
|