function hook_protected_twig_namespaces_alter in Components! 8.2
Same name and namespace in other branches
- 3.x components.api.php \hook_protected_twig_namespaces_alter()
Alter the list of protected Twig namespaces.
Parameters
array $protectedNamespaces: The array of protected Twig namespaces, keyed on the machine name of the namespace. Within each array entry, the following pieces of data are available:
- name: While the array key is the default Twig namespace (which is also the machine name of the module/theme that owns it), this "name" is the friendly name of the module/theme used in Drupal's admin lists.
- type: The extension type: module, theme, or profile.
- package: The package name the module is listed under or an empty string.
See also
https://www.drupal.org/node/3190969
1 function implements hook_protected_twig_namespaces_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- components_test_protected_twig_namespaces_alter in tests/
modules/ components_test/ components_test.module - Implements hook_protected_twig_namespaces_alter().
1 invocation of hook_protected_twig_namespaces_alter()
- ComponentsInfo::init in src/
Template/ ComponentsInfo.php - Initializes the registry and loads the theme namespaces.
File
- ./
components.api.php, line 28 - Hooks related to the Components module.
Code
function hook_protected_twig_namespaces_alter(array &$protectedNamespaces) {
// Allow the "block" Twig namespace to be altered.
unset($protectedNamespaces['block']);
// Allow alteration of any Twig namespace for a "Core" module.
foreach ($protectedNamespaces as $name => $info) {
if ($info['package'] === 'Core') {
unset($protectedNamespaces[$name]);
}
}
// Allow alteration of any Twig namespace for any theme.
foreach ($protectedNamespaces as $name => $info) {
if ($info['type'] === 'theme') {
unset($protectedNamespaces[$name]);
}
}
// Allow alteration of all Twig namespaces.
$protectedNamespaces = [];
}