|
|
|
|
@ -87,6 +87,7 @@ class TwigTweakExtension extends AbstractExtension {
|
|
|
|
|
new TwigFunction('drupal_breakpoint', [self::class, 'drupalBreakpoint'], $all_options), |
|
|
|
|
// @phpcs:ignore Drupal.Arrays.Array.LongLineDeclaration |
|
|
|
|
new TwigFunction('drupal_contextual_links', [self::class, 'drupalContextualLinks']), |
|
|
|
|
new TwigFunction('drupal_settings', [self::class, 'drupalSettings']), |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$this->moduleHandler->alter('twig_tweak_functions', $functions); |
|
|
|
|
@ -726,4 +727,21 @@ class TwigTweakExtension extends AbstractExtension {
|
|
|
|
|
return $output; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieves data from settings. |
|
|
|
|
* |
|
|
|
|
* @param string $key |
|
|
|
|
* A string that maps to a key within the settings data. |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
* The settings string value or an error message. |
|
|
|
|
*/ |
|
|
|
|
public static function drupalSettings(string $key) { |
|
|
|
|
if (Settings::get($key) && is_string(Settings::get($key))) { |
|
|
|
|
return Settings::get($key); |
|
|
|
|
} else { |
|
|
|
|
return 'Settings value is not a string'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|