1 | <?php |
||
26 | class UtilityTwigExtension extends AbstractTwigExtension { |
||
27 | |||
28 | /** |
||
29 | * Service name. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | const SERVICE_NAME = "webeweb.core.twig.extension.utility"; |
||
34 | |||
35 | /** |
||
36 | * Calculates an age. |
||
37 | * |
||
38 | * @param DateTime $birthDate The birth date. |
||
39 | * @param DateTime|null $refDate The reference date. |
||
40 | * @return int Returns teh age. |
||
41 | * @throws Exception Throws an exception if an error occurs. |
||
42 | */ |
||
43 | public function calcAge(DateTime $birthDate, DateTime $refDate = null) { |
||
46 | |||
47 | /** |
||
48 | * Format a date/time. |
||
49 | * |
||
50 | * @param DateTime|null $dateTime The date/time. |
||
51 | * @param string $format The format. |
||
52 | * @return string Returns the formatted date/time. |
||
53 | */ |
||
54 | public function formatDate(DateTime $dateTime = null, $format = DateTimeRenderer::DATETIME_FORMAT) { |
||
57 | |||
58 | /** |
||
59 | * Get the Twig filters. |
||
60 | * |
||
61 | * @return Twig_SimpleFilter[] Returns the Twig filters. |
||
62 | */ |
||
63 | public function getFilters() { |
||
72 | |||
73 | /** |
||
74 | * Get the Twig functions. |
||
75 | * |
||
76 | * @return array Returns the Twig functions. |
||
77 | */ |
||
78 | public function getFunctions() { |
||
87 | |||
88 | /** |
||
89 | * Decodes HTML entities. |
||
90 | * |
||
91 | * @param string $string The string. |
||
92 | * @return string Returns the decoded HTML entities. |
||
93 | */ |
||
94 | public function htmlEntityDecode($string) { |
||
100 | |||
101 | /** |
||
102 | * Encodes HTML entities. |
||
103 | * |
||
104 | * @param string $string The string. |
||
105 | * @return string Returns the encoded HTML entities. |
||
106 | */ |
||
107 | public function htmlEntityEncode($string) { |
||
113 | |||
114 | /** |
||
115 | * MD5. |
||
116 | * |
||
117 | * @param string $string The string. |
||
118 | * @return string Returns the MD5. |
||
119 | */ |
||
120 | public function md5($string) { |
||
126 | } |
||
127 |