Improve utils::Sanitize()

- Add class constants for $sSanitizationFilter values (You should use them instead of hard-coding the value, for example: utils::ENUM_SANIZATION_FILTER_XXX)
- Fix "element_identifier" filter of utils::Sanitize() to keep "-" character
- Add 'sanitize_identifier' filter to TWIG
This commit is contained in:
Molkobain
2020-10-05 09:46:21 +02:00
parent dc24bbcd97
commit e911290b3d
2 changed files with 42 additions and 15 deletions

View File

@@ -86,6 +86,13 @@ class Extension
})
);
// Filter to sanitize an XML / HTML identifier
// Usage in twig: {{ 'identifier:to-sanitize' }}
$oTwigEnv->addFilter(new Twig_SimpleFilter('sanitize_identifier', function($sString) {
return utils::Sanitize($sString, '', utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER);
})
);
// Filter to add a parameter at the end of the URL to force cache invalidation after an upgrade.
// Previously we put the iTop version but now it's the last setup/toolkit timestamp to avoid cache issues when building several times the same version during tests
//