-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smarty::setExtensions() killing registered filters #1006
Comments
Yes, if you also want the BCPluginsAdapter, you could also do this: $smarty->setExtensions([
new Smarty\Extension\CoreExtension(),
new MyCustomExtension(),
new Smarty\Extension\DefaultExtension(),
new Smarty\Extension\BCPluginsAdapter($smarty),
]); I didn't document that because I thought people who write custom Extensions and insert them before the default ones probably don't need the BCPluginsAdapter anymore. |
Ok. But am I really supposed to create (yet another) extension, just to register a filter? This seems kind of overkill to me. |
No, you don't need to. But if you are creating a custom extension anyway, why not put everything you need in there? |
The custom extension is created and included in my framework. One single call in the application using that framework needs a special output filter, and it took me quite a while to figure out why it is ignored. What else besides the (deprecated?) |
Add public function getOutputFilters(): array {
return [ ];
} to your MyCustomExtension and return an object that implements For example: class MyReverseFilter implements \Smarty\Filter\FilterInterface {
public function filter($code, \Smarty\Template $template) {
return strrev($code);
}
} Btw: you are right about the documentation. It needs more love. |
From a logical point of view MyCustomExtension is the wrong place. Perhaps I'll create a second, controller-specific extension, I'll have to think about it. |
Instructions to add output filters are:
Instructions to add custom extensions (overriding the defaults) are:
Unfortunately the latter kills $smarty->BCPluginsAdapter thus disabling any filters. I solved the problem by using:
I don't like the style, but at least it is working. But something must be done here, either in the API, or at least the documentation should be updated.
The text was updated successfully, but these errors were encountered: