Skip to content

Commit

Permalink
feat: ✨ add URL twig function
Browse files Browse the repository at this point in the history
  • Loading branch information
woldtwerk committed Jul 30, 2024
1 parent 62d9be6 commit dece05e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getFunctions() {
new TwigFunction('buttons', [$this, 'getButtons']),
new TwigFunction('buttons', [$this, 'getButtons']),
new TwigFunction('languages', [$this, 'getLanguages']),
new TwigFunction('ue_url', [$this, 'urlFromUserInput']),
];
}

Expand Down Expand Up @@ -340,4 +341,15 @@ public function getLanguages($language = NULL) {

return $langs;
}

/**
* Return a Drupal URL object.
*
* @param string $url
* @return static
* A new Url object based on user input.
*/
public function urlFromUserInput(string $url) {
return \Drupal\Core\Url::fromUserInput($url);
}
}

0 comments on commit dece05e

Please sign in to comment.