Completed
Push — master ( dfe684...c4d587 )
by WEBEWEB
06:45
created

__construct()   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 core-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\CoreBundle\Twig\Extension\Plugin;
13
14
use Twig_Environment;
15
use Twig_SimpleFilter;
16
use Twig_SimpleFunction;
17
use WBW\Bundle\CoreBundle\Renderer\IconRendererInterface;
18
use WBW\Bundle\CoreBundle\Twig\Extension\Plugin\AbstractMaterialDesignIconicFontTwigExtension;
19
use WBW\Library\Core\Argument\ArrayHelper;
20
21
/**
22
 * Material Design Iconic Font Twig extension.
23
 *
24
 * @author webeweb <https://github.com/webeweb/>
25
 * @package WBW\Bundle\CoreBundle\Twig\Extension\Plugin
26
 */
27
class MaterialDesignIconicFontTwigExtension extends AbstractMaterialDesignIconicFontTwigExtension implements IconRendererInterface {
28
29
    /**
30
     * Service name.
31
     *
32
     * @var string
33
     */
34
    const SERVICE_NAME = "webeweb.core.twig.extension.plugin.material_design_iconic_font";
35
36
    /**
37
     * Constructor.
38
     *
39
     * @param Twig_Environment $twigEnvironment The wig environment.
40
     */
41
    public function __construct(Twig_Environment $twigEnvironment) {
42
        parent::__construct($twigEnvironment);
43
    }
44
45
    /**
46
     * Get the Twig filters.
47
     *
48
     * @return Twig_SimpleFilter[] Returns the Twig filters.
49
     */
50
    public function getFilters() {
51
        return [
52
            new Twig_SimpleFilter("materialDesignIconicFontList", [$this, "materialDesignIconicFontListFilter"], ["is_safe" => ["html"]]),
53
            new Twig_SimpleFilter("materialDesignIconicFontListIcon", [$this, "materialDesignIconicFontListIconFilter"], ["is_safe" => ["html"]]),
54
        ];
55
    }
56
57
    /**
58
     * Get the Twig functions.
59
     *
60
     * @return array Returns the Twig functions.
61
     */
62
    public function getFunctions() {
63
        return [
64
            new Twig_SimpleFunction("materialDesignIconicFontIcon", [$this, "materialDesignIconicFontIconFunction"], ["is_safe" => ["html"]]),
65
        ];
66
    }
67
68
    /**
69
     * Displays a Material Design Iconic Font icon.
70
     *
71
     * @param array $args The arguments.
72
     * @return string Returns the Material Design Iconic Font icon.
73
     */
74
    public function materialDesignIconicFontIconFunction(array $args = []) {
75
        return $this->materialDesignIconicFontIcon(ArrayHelper::get($args, "name", "home"), ArrayHelper::get($args, "size"), ArrayHelper::get($args, "fixedWidth", false), ArrayHelper::get($args, "border", false), ArrayHelper::get($args, "pull"), ArrayHelper::get($args, "spin"), ArrayHelper::get($args, "rotate"), ArrayHelper::get($args, "flip"), ArrayHelper::get($args, "style"));
76
    }
77
78
    /**
79
     * Displays a Material Design Iconic Font list.
80
     *
81
     * @param array|string $items The items.
82
     * @return string Returns the Material Design Iconic Font list.
83
     */
84
    public function materialDesignIconicFontListFilter($items) {
85
        return $this->materialDesignIconicFontList($items);
86
    }
87
88
    /**
89
     * Displays a Material Design Iconic Font list icon.
90
     *
91
     * @param string $icon The icon.
92
     * @param string $content The content.
93
     * @return string Returns the Material Design Iconic Font list icon.
94
     */
95
    public function materialDesignIconicFontListIconFilter($icon, $content) {
96
        return $this->materialDesignIconicFontListIcon($icon, $content);
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function renderIcon($name, $style) {
103
        return $this->materialDesignIconicFontIconFunction(["name" => $name, "style" => $style]);
104
    }
105
106
}
107