diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 0c1ee37..29b5669 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -77,6 +77,7 @@ public function getFunctions() { new \Twig_SimpleFunction('url_from_path', array($this, 'getUrlFromPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), new \Twig_SimpleFunction('link', array($this, 'getLink')), new \Twig_SimpleFunction('file_url', 'file_create_url'), + new \Twig_SimpleFunction('active_theme_path', 'activeThemePath'), ); } @@ -217,6 +218,16 @@ public function getLink($text, $url) { } /** + * Gets the path of the active theme. + * + * @return string + * The path to the active theme. + */ + public function activeThemePath() { + return \Drupal::service('theme.manager')->getActiveTheme()->getPath(); + } + + /** * Determines at compile time whether the generated URL will be safe. * * Saves the unneeded automatic escaping for performance reasons.