PrestaShop / PrestaShop/TranslationToolsBundle
Use a callback to catch undefined Twig function
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 5
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Actually, we have to define again all Twig functions available in PrestaShop codebase to empty them.
Else, Twig throws an exception and the parsing fails.
This could be really MORE EFFICIENT to use the defined callback for it: http://twig.sensiolabs.org/doc/recipes.html#defining-undefined-functions-and-filters-on-the-fly
$twig->registerUndefinedFunctionCallback(function ($name) {
return new Twig_SimpleFunction($name, array($this, 'emptyFunction'));
});
But we need to enable this callback only in context of our own Translation tool.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Translation tool's Twig setup and the code that redefines available functions as empty functions. Check how registerUndefinedFunctionCallback can be enabled only for this tool, then verify that undefined functions no longer require individual definitions and translation parsing still succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- localization
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100