Twig extension : a new filter #16

webornot opened this Issue Apr 21, 2011 · 3 comments

5 participants


There is a filter called date using php DateTime Object but it doesn't allow formatting as the locale of the user. That's why I wanted to created a new filter using the extension "Intl". This works fine when I put the finction in "core.php" but when I want to extend twig extension with "Twig_Filter_Method()", no php native functions and classes is recognized. I can't use php function inside the new function created by me.

For example : "Fatal error: Class 'Application\BlogBundle\Twig\DateTime' not found" or "Fatal error: Class 'Application\BlogBundle\Twig\IntlDateFormatter' not found".

What's wrong ? et why twig doesn't use a filter for convert the date about locale.


You should write \DateTime and \IntlDateFormatter instead of DateTime and IntlDateFormatter (note the \ in front of both) so it refers to the classes of the global namespace.


btw, see #30 for a PR adding such a filter in this repo.


@webornot : yes , as stof said (a year ago) :) . can you close the ticket please?

@fabpot fabpot closed this Apr 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment