|
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 Twig\TwigFunction; |
|
15
|
|
|
use WBW\Library\Core\Argument\Helper\ArrayHelper; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Radio button Twig extension. |
|
19
|
|
|
* |
|
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
21
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Form |
|
22
|
|
|
*/ |
|
23
|
|
|
class RadioButtonTwigExtension extends AbstractRadioButtonTwigExtension { |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Service name. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
const SERVICE_NAME = "wbw.adminbsb.twig.extension.form.radio_button"; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Displays an AdminBSB radio button "Basic". |
|
34
|
|
|
* |
|
35
|
|
|
* @param array $args The arguments. |
|
36
|
|
|
* @return string Returns the AdminBSB radio button "Basic". |
|
37
|
|
|
*/ |
|
38
|
|
|
public function adminBSBRadioButtonBasicFunction(array $args = []): string { |
|
39
|
|
|
return $this->adminBSBRadioButton(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "name"), ArrayHelper::get($args, "id"), ArrayHelper::get($args, "checked", false), ArrayHelper::get($args, "disabled", false), ArrayHelper::get($args, "withGap", false), ArrayHelper::get($args, "class")); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Displays an AdminBSB radio button "Material design". |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $args The arguments. |
|
46
|
|
|
* @return string Returns the AdminBSB radio button "Material design". |
|
47
|
|
|
*/ |
|
48
|
|
|
public function adminBSBRadioButtonMaterialDesignFunction(array $args = []): string { |
|
49
|
|
|
return $this->adminBSBRadioButton(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "name"), ArrayHelper::get($args, "id"), ArrayHelper::get($args, "checked", false), ArrayHelper::get($args, "disabled", false), ArrayHelper::get($args, "withGap", false), ArrayHelper::get($args, "class", "") . static::materialDesignColor(ArrayHelper::get($args, "color", "red"), " radio-col-")); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get the Twig functions. |
|
54
|
|
|
* |
|
55
|
|
|
* @return TwigFunction[] Returns the Twig functions. |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getFunctions(): array { |
|
58
|
|
|
return [ |
|
59
|
|
|
new TwigFunction("adminBSBRadioButtonBasic", [$this, "adminBSBRadioButtonBasicFunction"], ["is_safe" => ["html"]]), |
|
60
|
|
|
new TwigFunction("adminBSBRadioButtonMaterialDesign", [$this, "adminBSBRadioButtonMaterialDesignFunction"], ["is_safe" => ["html"]]), |
|
61
|
|
|
]; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|