1 | <?php |
||
24 | class HtmlExtension extends AbstractTwigExtension implements EngineExtensionInterface |
||
25 | { |
||
26 | /** |
||
27 | * For url parse |
||
28 | */ |
||
29 | use UrlUtils; |
||
30 | |||
31 | /** |
||
32 | * @var Request |
||
33 | */ |
||
34 | protected $request; |
||
35 | |||
36 | /** |
||
37 | * Returns the name of the extension. |
||
38 | * |
||
39 | * @return string The extension name |
||
40 | */ |
||
41 | 2 | public function getName() |
|
45 | |||
46 | /** |
||
47 | * Returns a list of functions to add to the existing list. |
||
48 | * |
||
49 | * @return array An array of functions |
||
50 | */ |
||
51 | 2 | public function getFunctions() |
|
52 | { |
||
53 | return [ |
||
54 | new SimpleFunction('url', function($url) { |
||
|
|||
55 | $args = func_get_args(); |
||
56 | return call_user_func_array([$this, 'getUrl'], $args); |
||
57 | 2 | }), |
|
58 | 2 | new SimpleFunction( |
|
59 | 2 | 'addCss', |
|
60 | function($file, $path='/css', $attr = []) { |
||
61 | return $this->addCss($file, $path, $attr); |
||
62 | } |
||
63 | 2 | ), |
|
64 | 2 | new SimpleFunction( |
|
65 | 2 | 'addJs', |
|
66 | function($file, $path='/javascripts') { |
||
67 | return $this->addJs($file, $path); |
||
68 | } |
||
69 | 2 | ) |
|
70 | 2 | ]; |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * Get request |
||
75 | * @return Request |
||
76 | */ |
||
77 | 2 | public function getRequest() |
|
84 | |||
85 | /** |
||
86 | * Set HTML request message |
||
87 | * |
||
88 | * @param Request $request |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 10 | public function setRequest(Request $request) |
|
97 | |||
98 | /** |
||
99 | * Creates an HTML style tag |
||
100 | * |
||
101 | * @param string $file |
||
102 | * @param string $path |
||
103 | * @param array $attr |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 2 | public function addCss($file, $path='/css', $attr = []) |
|
118 | |||
119 | 2 | public function addJs($file, $path='/javascripts') |
|
124 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.