From 03da5f2bdf80669eef2d61fff2891dd3c0d12b3d Mon Sep 17 00:00:00 2001 From: seanpenn079 Date: Sat, 1 May 2021 21:02:01 +0500 Subject: [PATCH] Issue #3188441 by seanB, Wilfred Waltman: Allow arguments to be passed to token_replace --- src/TwigExtension.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/TwigExtension.php b/src/TwigExtension.php index d61d37b..af449d4 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -1016,12 +1016,21 @@ class TwigExtension extends AbstractExtension { * * @param string $text * An HTML string containing replaceable tokens. + * @param array $data + * (optional) An array of keyed objects. For simple replacement scenarios + * 'node', 'user', and others are common keys, with an accompanying node or + * user object being the value. Some token types, like 'site', do not + * require any explicit information from $data and can be replaced even if + * it is empty. + * @param array $options + * (optional) A keyed array of settings and flags to control the token + * replacement process. * * @return string * The entered HTML text with tokens replaced. */ - public function tokenReplaceFilter($text) { - return \Drupal::token()->replace($text); + public function tokenReplaceFilter($text, array $data = [], array $options = []) { + return \Drupal::token()->replace($text, $data, $options); } /**