After enabling Token and Redirect modules, I've found at /admin/help/token
that I can use Redirect tokens. For example:
However, I've got the problem finding the place where and how these tokens are defined (which file and hook or class).
Any ideas?
I've tried to search inside all files in docroot, e.g.
$ grep -r "The URL of the redirect" .
(nothing)
$ grep -r "The URL of the" .
(returns everything apart of redirect, no matching placeholders found)
$ grep -r token modules/contrib/redirect/
modules/contrib/redirect/config/install/views.view.redirect.yml: tokenize: false
modules/contrib/redirect/modules/redirect_404/config/install/views.view.redirect_404.yml: tokenize: false
modules/contrib/redirect/modules/redirect_404/redirect_404.routing.yml: _csrf_token: 'TRUE'
modules/contrib/redirect/src/EventSubscriber/RouteNormalizerRequestSubscriber.php: // Strip off query parameters added by the route such as a CSRF token.
$ grep -r redirect modules/contrib/token/
modules/contrib/token/src/Controller/TokenCacheController.php: * Clear caches and redirect back to the frontpage.
modules/contrib/token/src/Controller/TokenCacheController.php: return $this->redirect('<front>');
$ find modules/contrib/redirect modules/contrib/token -name "*.tokens.inc"
modules/contrib/token/tests/modules/token_module_test/token_module_test.tokens.inc
modules/contrib/token/token.tokens.inc (Note: nothing here for redirect)
So basically I couldn't find the source which module is defining those. This can help me in order to find out, why some of them aren't working as expected.
The main reason I ask this, because I would expect for redirect URL such as /foo/XXX
, to return XXX
when using [redirect:url:args:last]
, but these tokens aren't populated at all.
redirect
is an entity type - tokens are provided for its base and other fields automagically[redirect:url:args:last]
will give me the last part of the URL of the redirect path, but it doesn't work at all. So making redirect like/foo/XXX
, I would expect that[redirect:url:args:last]
would return meXXX
. However, since these are dynamically created somewhere in core, I think they're useless then.foo/{arg}
. But if the route isfoo/bar
, static, then it doesn’t contain any parameters, so the token would be empty