Completed
Push — master ( 67a554...0f9f47 )
by WEBEWEB
02:09
created

adminBSBDatetimePickerFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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