Completed
Push — master ( 064006...20444a )
by WEBEWEB
04:40
created

DataTablesTwigExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the jquery-datatables-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\JQuery\DataTablesBundle\Twig\Extension;
13
14
use Twig_SimpleFunction;
15
use WBW\Bundle\JQuery\DataTablesBundle\API\DataTablesWrapper;
16
use WBW\Library\Core\Utility\Argument\ArrayUtility;
17
18
/**
19
 * DataTables Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\JQuery\DataTablesBundle\Twig\Extension
23
 */
24
class DataTablesTwigExtension extends AbstractDataTablesTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.bundle.datatablesbundle.twig.extension.datatables";
32
33
    /**
34
     * Constructor.
35
     */
36
    public function __construct() {
37
        parent::__construct();
38
    }
39
40
    /**
41
     * Displays a DataTables HTML.
42
     *
43
     * @param DataTablesWrapper $dtWrapper The wrapper.
44
     * @param array $args The arguments.
45
     * @return string Returns the DataTables HTML.
46
     */
47
    public function dataTablesHTMLFunction(DataTablesWrapper $dtWrapper, array $args = []) {
48
        return $this->dataTablesTable($dtWrapper, ArrayUtility::get($args, "class"), ArrayUtility::get($args, "thead", true), ArrayUtility::get($args, "tfoot", true));
49
    }
50
51
    /**
52
     * Get the Twig functions.
53
     *
54
     * @return array Returns the Twig functions.
55
     */
56
    public function getFunctions() {
57
        return [
58
            new Twig_SimpleFunction("dataTablesHTML", [$this, "dataTablesHTMLFunction"], ["is_safe" => ["html"]]),
59
        ];
60
    }
61
62
}
63