1 | <?php |
||
20 | class TwigExtensions { |
||
21 | |||
22 | /** |
||
23 | * Formats the given time value to a timestring defined by the $pattern |
||
24 | * parameter. |
||
25 | * |
||
26 | * If the value is false (like null), an empty string is |
||
27 | * returned. Else, the value is tried to be parsed as datetime via the |
||
28 | * given pattern. If that fails, it is tried to be parsed with the pattern |
||
29 | * 'Y-m-d H:i:s'. If that fails, the value is returned unchanged. Else, it |
||
30 | * is returned formatted with the given pattern. The effect is to shorten |
||
31 | * 'Y-m-d H:i:s' to 'Y-m-d' for example. |
||
32 | * |
||
33 | * @param string $value |
||
34 | * the value to be formatted |
||
35 | * @param string $timezone |
||
36 | * the timezone of the value |
||
37 | * @param string $pattern |
||
38 | * the pattern with which the value is parsed and formatted |
||
39 | * |
||
40 | * @return string |
||
41 | * the formatted value |
||
42 | */ |
||
43 | protected function formatTime($value, $timezone, $pattern) { |
||
57 | |||
58 | /** |
||
59 | * Registers all extensions. |
||
60 | * |
||
61 | * @param Container $app |
||
62 | * the current application |
||
63 | */ |
||
64 | public function registerTwigExtensions(Container $app) { |
||
76 | |||
77 | /** |
||
78 | * Gets a language name in the given language. |
||
79 | * |
||
80 | * @param string $language |
||
81 | * the language code of the desired language name |
||
82 | * |
||
83 | * @return string |
||
84 | * the language name in the given language or null if not available |
||
85 | */ |
||
86 | public function getLanguageName($language) { |
||
89 | |||
90 | /** |
||
91 | * Formats a float to not display in scientific notation. |
||
92 | * |
||
93 | * @param float $float |
||
94 | * the float to format |
||
95 | * |
||
96 | * @return double|string |
||
97 | * the formated float |
||
98 | */ |
||
99 | public function formatFloat($float) { |
||
115 | |||
116 | /** |
||
117 | * Formats the given value to a date of the format 'Y-m-d'. |
||
118 | * |
||
119 | * @param string $value |
||
120 | * the value, might be of the format 'Y-m-d H:i' or 'Y-m-d' |
||
121 | * @param boolean $isUTC |
||
122 | * whether the given value is in UTC |
||
123 | * |
||
124 | * @return string |
||
125 | * the formatted result or an empty string on null value |
||
126 | */ |
||
127 | public function formatDate($value, $isUTC) { |
||
131 | |||
132 | /** |
||
133 | * Formats the given value to a date of the format 'Y-m-d H:i'. |
||
134 | * |
||
135 | * @param string $value |
||
136 | * the value, might be of the format 'Y-m-d H:i' |
||
137 | * @param boolean $isUTC |
||
138 | * whether the given value is in UTC |
||
139 | * |
||
140 | * @return string |
||
141 | * the formatted result or an empty string on null value |
||
142 | */ |
||
143 | public function formatDateTime($value, $isUTC) { |
||
147 | |||
148 | } |
||
149 |