Skip to content
Snippets Groups Projects
Commit 466f816c authored by jurgenhaas's avatar jurgenhaas
Browse files

Add patch for token module

parent 2c540452
No related branches found
No related tags found
1 merge request!173Merging develop into main
Pipeline #1203507 passed with warnings
......@@ -241,6 +241,9 @@
"drupal/title": {
"#3172331 D9 compatibility": "https://www.drupal.org/files/issues/2021-08-24/D9-compatibility_3172331.patch"
},
"drupal/token": {
"#3437013 Referrer tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3437013.diff"
},
"drupal/uikitty": {
"#3149175 Drupal 9": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3149175.diff",
"#local Drupal 10": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/uikitty-d10.patch"
......
......@@ -234,6 +234,9 @@
"drupal/title": {
"#3172331 D9 compatibility": "https://www.drupal.org/files/issues/2021-08-24/D9-compatibility_3172331.patch"
},
"drupal/token": {
"#3437013 Referrer tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3437013.diff"
},
"drupal/uikitty": {
"#3149175 Drupal 9": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3149175.diff",
"#local Drupal 10": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/uikitty-d10.patch"
......
diff --git a/token.tokens.inc b/token.tokens.inc
index f8925aa61c359a1983c3dd9fcf2dba5e798c8035..6a6f9b88eccf877fcda3ddb4cc64b924090c9c68 100644
--- a/token.tokens.inc
+++ b/token.tokens.inc
@@ -339,6 +339,11 @@ function token_token_info() {
'description' => t('The URL of the current page.'),
'type' => 'url',
];
+ $info['tokens']['current-page']['referrer-url'] = [
+ 'name' => t('Referrer URL'),
+ 'description' => t('The URL of the current page referrer.'),
+ 'type' => 'url',
+ ];
$info['tokens']['current-page']['page-number'] = [
'name' => t('Page number'),
'description' => t('The page number of the current page when viewing paged lists.'),
@@ -348,6 +353,11 @@ function token_token_info() {
'description' => t('The value of a specific query string field of the current page.'),
'dynamic' => TRUE,
];
+ $info['tokens']['current-page']['referrer-query'] = [
+ 'name' => t('Referrer query string value'),
+ 'description' => t('The value of a specific query string field of the current page referrer.'),
+ 'dynamic' => TRUE,
+ ];
$info['tokens']['current-page']['interface-language'] = [
'name' => t('Interface language'),
'description' => t('The active user interface language.'),
@@ -904,6 +914,10 @@ function token_tokens($type, array $tokens, array $data, array $options, Bubblea
}
break;
+ case 'referrer-url':
+ $replacements[$original] = \Drupal::request()->headers->get('referer')
+ break;
+
case 'page-number':
if ($page = $request->query->get('page')) {
// @see PagerDefault::execute()
@@ -952,6 +966,22 @@ function token_tokens($type, array $tokens, array $data, array $options, Bubblea
}
}
+ // [current-page:referrer-query] dynamic tokens.
+ if ($query_tokens = \Drupal::token()->findWithPrefix($tokens, 'referrer-query')) {
+ if ($referrer = \Drupal::request()->headers->get('referer')) {
+ if ($query = parse_url($referrer, PHP_URL_QUERY)) {
+ $queryArgs = [];
+ foreach (explode('&', $query) as $item) {
+ [$key, $value] = explode('=', $item);
+ $queryArgs[$key] = urldecode($value);
+ }
+ foreach ($query_tokens as $name => $original) {
+ $replacements[$original] = $queryArgs[$name] ?? '';
+ }
+ }
+ }
+ }
+
// Chained token relationships.
if ($url_tokens = \Drupal::token()->findWithPrefix($tokens, 'url')) {
$url = NULL;
......@@ -238,6 +238,9 @@
"drupal/title": {
"#3172331 D9 compatibility": "https://www.drupal.org/files/issues/2021-08-24/D9-compatibility_3172331.patch"
},
"drupal/token": {
"#3437013 Referrer tokens": "https://gitlab.lakedrops.com/composer/plugin/drupal-environment/-/raw/main/patches/d10/3437013.diff"
},
"drupal/uikitty": {
"#3149175 Drupal 9": "https://git.drupalcode.org/project/uikitty/-/merge_requests/2.diff"
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment