1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the adminbsb-material-design-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 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\Plugin; |
13
|
|
|
|
14
|
|
|
use Twig\TwigFunction; |
15
|
|
|
use WBW\Library\Core\Argument\Helper\ArrayHelper; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Datetime picker Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Plugin |
22
|
|
|
*/ |
23
|
|
|
class DatetimePickerTwigExtension extends AbstractDatetimePickerTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Service name. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
const SERVICE_NAME = "wbw.adminbsb.twig.extension.plugin.datetime_picker"; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Displays an AdminBSB date picker. |
34
|
|
|
* |
35
|
|
|
* @param array $args The arguments. |
36
|
|
|
* @return string Returns the AdminBSB date picker. |
37
|
|
|
*/ |
38
|
|
|
public function adminBSBDatePickerFunction(array $args = []): string { |
39
|
|
|
return $this->adminBSBDatetimePicker(ArrayHelper::get($args, "selector"), ArrayHelper::get($args, "clearButton", false), true, ArrayHelper::get($args, "format", self::DEFAULT_DATE_FORMAT), ArrayHelper::get($args, "lang", "en"), false, ArrayHelper::get($args, "weekStart", 0)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Displays a AdminBSB datetime picker. |
44
|
|
|
* |
45
|
|
|
* @param array $args The arguments. |
46
|
|
|
* @return string Returns the AdminBSB datetime picker. |
47
|
|
|
*/ |
48
|
|
|
public function adminBSBDatetimePickerFunction(array $args = []): string { |
49
|
|
|
return $this->adminBSBDatetimePicker(ArrayHelper::get($args, "selector"), ArrayHelper::get($args, "clearButton", false), ArrayHelper::get($args, "date", true), ArrayHelper::get($args, "format", self::DEFAULT_DATETIME_FORMAT), ArrayHelper::get($args, "lang", "en"), ArrayHelper::get($args, "time", true), ArrayHelper::get($args, "weekStart", 0)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Displays a time picker. |
54
|
|
|
* |
55
|
|
|
* @param array $args The arguments. |
56
|
|
|
* @return string Returns the AdminBSB time picker. |
57
|
|
|
*/ |
58
|
|
|
public function adminBSBTimePickerFunction(array $args = []): string { |
59
|
|
|
return $this->adminBSBDatetimePicker(ArrayHelper::get($args, "selector"), ArrayHelper::get($args, "clearButton", false), false, ArrayHelper::get($args, "format", self::DEFAULT_TIME_FORMAT), ArrayHelper::get($args, "lang", "en"), true, 0); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get the Twig functions. |
64
|
|
|
* |
65
|
|
|
* @return TwigFunction[] Returns the Twig functions. |
66
|
|
|
*/ |
67
|
|
|
public function getFunctions(): array { |
68
|
|
|
return [ |
69
|
|
|
new TwigFunction("adminBSBDatePicker", [$this, "adminBSBDatePickerFunction"], ["is_safe" => ["html"]]), |
70
|
|
|
new TwigFunction("adminBSBDatetimePicker", [$this, "adminBSBDatetimePickerFunction"], ["is_safe" => ["html"]]), |
71
|
|
|
new TwigFunction("adminBSBTimePicker", [$this, "adminBSBTimePickerFunction"], ["is_safe" => ["html"]]), |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|