07.
Adding a Twig Extension + DI Tags
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
8 Comments
Hi Ryan,
in my PHPStorm, I can not see the Twig_ExtensionInterface in the implemented methods (Cmd+N menu). Do I need to install any plugin to see it?
Starting with 3.2 Symfony deprecated getName() function in Twig_Extension class, now it's enough to just override the getFilters() method. More info here http://symfony.com/doc/curr....
Woohoo! You're right! That's an awesome improvement.
To clarify, starting in Twig 1.26 (released October 2nd, 2016), you do not need the
getNamemethod anymore. So when you go to "Implement Methods",getNamewill not show up anymore. And that's totally fine - just skip it (i.e. don't add it).Thanks Vadim for the comment!
Hey Tin,
No, it should be available out-of-the-box. Do you choose the "Implement methods" option in "Generate" menu? Please, also double check that your `MarkdownExtension` extends `\Twig_Extension` class. Do you use the latest PhpStorm version? Probably you just need to restart PhpStorm - it should help in most cases.
Cheers!
Hi Victor, Thank you for your reply but I still didn't have that getName() method from the "Implement methods" in "Generated" menu.
On the other hand, the override methods is fine.
My PhpStorm version is up to date and I did try to restart it.
I decided to ignore this small bug and move on!
Ah, that's weird. If you add vendor dir to excluded folders - I think it may cause this issue too. But if not, I can suggest you to re-index your project. AFAIK, you need to choose "File" -> "Invalidate Caches". I hope it will help.
Cheers!
Same problem with PHPStorm 10 on Windows. Invalidating Cache did not work. Strange, but not a show stopper.
EDITED
Oh wait, not strange. I probably have a later version of twig which already implements the getName method so it shows up in overrides instead.
Hey Maria,
Ah, it makes sense! Thanks for sharing this with us. Agnes , please, check Maria's answer about your problem. I bet you will find this method in "Override" menu.
Cheers!
"Houston: no signs of life"
Start the conversation!