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 Symfony\Component\Translation\TranslatorInterface; |
15
|
|
|
use Twig_SimpleFunction; |
16
|
|
|
use WBW\Library\Core\Helper\Argument\ArrayHelper; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Datetime picker Twig extension. |
20
|
|
|
* |
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
22
|
|
|
* @package WBW\Bundle\AdminBSBBundle\Twig\Extension\Plugin |
23
|
|
|
*/ |
24
|
|
|
class DatetimePickerTwigExtension extends AbstractDatetimePickerTwigExtension { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Service name. |
28
|
|
|
* |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
const SERVICE_NAME = "webeweb.adminbsbbundle.twig.extension.plugin.datetimepicker"; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Constructor. |
35
|
|
|
* |
36
|
|
|
* @param TranslatorInterface $translator The translator. |
37
|
|
|
*/ |
38
|
|
|
public function __construct(TranslatorInterface $translator) { |
39
|
|
|
parent::__construct($translator); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Displays an AdminBSB date picker. |
44
|
|
|
* |
45
|
|
|
* @param $args The arguments. |
46
|
|
|
* @return string Returns the AdminBSB date picker. |
47
|
|
|
*/ |
48
|
|
|
public function adminBSBDatePickerFunction(array $args = []) { |
49
|
|
|
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)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Displays a AdminBSB datetime picker. |
54
|
|
|
* |
55
|
|
|
* @param $args The arguments. |
56
|
|
|
* @return string Returns the AdminBSB datetime picker. |
57
|
|
|
*/ |
58
|
|
|
public function adminBSBDatetimePickerFunction(array $args = []) { |
59
|
|
|
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)); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Displays a time picker. |
64
|
|
|
* |
65
|
|
|
* @param $args The arguments. |
66
|
|
|
* @return string Returns the AdminBSB time picker. |
67
|
|
|
*/ |
68
|
|
|
public function adminBSBTimePickerFunction(array $args = []) { |
69
|
|
|
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); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get the Twig functions. |
74
|
|
|
* |
75
|
|
|
* @return array Returns the Twig functions. |
76
|
|
|
*/ |
77
|
|
|
public function getFunctions() { |
78
|
|
|
return [ |
79
|
|
|
new Twig_SimpleFunction("adminBSBDatePicker", [$this, "adminBSBDatePickerFunction"], ["is_safe" => ["html"]]), |
80
|
|
|
new Twig_SimpleFunction("adminBSBDatetimePicker", [$this, "adminBSBDatetimePickerFunction"], ["is_safe" => ["html"]]), |
81
|
|
|
new Twig_SimpleFunction("adminBSBTimePicker", [$this, "adminBSBTimePickerFunction"], ["is_safe" => ["html"]]), |
82
|
|
|
]; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|