1 | <?php |
||
8 | class ArrayExtension extends \Twig_Extension |
||
9 | { |
||
10 | /** |
||
11 | * Return extension name |
||
12 | * |
||
13 | * @return string |
||
14 | */ |
||
15 | public function getName() |
||
19 | |||
20 | /** |
||
21 | * Callback for Twig |
||
22 | * @ignore |
||
23 | */ |
||
24 | public function getFilters() |
||
34 | |||
35 | |||
36 | /** |
||
37 | * Calculate the sum of values in an array |
||
38 | * |
||
39 | * @param array $array |
||
40 | * @return int |
||
41 | */ |
||
42 | public function sum($array) |
||
46 | |||
47 | /** |
||
48 | * Calculate the product of values in an array |
||
49 | * |
||
50 | * @param array $array |
||
51 | * @return int |
||
52 | */ |
||
53 | public function product($array) |
||
57 | |||
58 | /** |
||
59 | * Return all the values of an array or object |
||
60 | * |
||
61 | * @param array|object $array |
||
62 | * @return array |
||
63 | */ |
||
64 | public function values($array) |
||
68 | |||
69 | /** |
||
70 | * Cast value to an array |
||
71 | * |
||
72 | * @param object|mixed $value |
||
73 | * @return array |
||
74 | */ |
||
75 | public function asArray($value) |
||
79 | |||
80 | /** |
||
81 | * Cast an array to an HTML attribute string |
||
82 | * |
||
83 | * @param mixed $array |
||
84 | * @return string |
||
85 | */ |
||
86 | public function htmlAttributes($array) |
||
107 | } |
||
108 |