N°4034 - Add the get_module_setting function to TwigBase.

This is temporary, as in the 3.1, this file will be deprecated in favor of `sources/application/TwigBase/Twig/Extension.php`.
More info in the N°4034.
This commit is contained in:
bruno-ds
2021-09-29 10:58:23 +02:00
parent c53c1d5b9c
commit 4297b854e1

View File

@@ -114,6 +114,14 @@ class TwigExtension
return $oConfig->Get($sParamName);
}));
// Function to get a module setting
// Usage in twig: {{ get_module_setting(<MODULE_CODE>, <PROPERTY_CODE> [, <DEFAULT_VALUE>]) }}
// since 3.0.0, but see N°4034 for upcoming evolutions in the 3.1
$oTwigEnv->addFunction(new Twig_SimpleFunction('get_module_setting', function (string $sModuleCode, string $sPropertyCode, $defaultValue = null) {
$oConfig = MetaModel::GetConfig();
return $oConfig->GetModuleSetting($sModuleCode, $sPropertyCode, $defaultValue);
}));
// Function to get the URL of a static page in a module
// Usage in twig: {{ get_static_page_module_url('itop-my-module', 'path-to-my-page') }}
$oTwigEnv->addFunction(new Twig_SimpleFunction('get_static_page_module_url', function($sModuleName, $sPage)