function replace_links_with_tokens in Menu Token 9.1.x
Same name and namespace in other branches
- 8 menu_token.module \replace_links_with_tokens()
Helper function for replacing links with token.
1 call to replace_links_with_tokens()
- menu_token_menu_links_discovered_alter in ./
menu_token.module - Replace links with tokens.
File
- ./
menu_token.module, line 382 - Contains menu_token.module.
Code
function replace_links_with_tokens(Token $token_service, $replace_with, $relevant_link, &$links, BubbleableMetadata $bubbleableMetadata) {
$uuId_from_link = substr($relevant_link['id'], strpos($relevant_link['id'], ":") + 1, strlen($relevant_link['id']));
$config_menu = \Drupal::entityTypeManager()
->getStorage('link_configuration_storage')
->load($uuId_from_link);
// Replace nothing to mess here all action is in hook.
if (!empty($config_menu)) {
$configuration = unserialize($config_menu->configurationSerialized);
$links[$relevant_link['id']][$replace_with] = $token_service
->replace($links[$relevant_link['id']][$replace_with], [], [
"configuration" => $configuration,
], $bubbleableMetadata);
if (is_null($links[$relevant_link['id']][$replace_with])) {
$links[$relevant_link['id']][$replace_with] = $token_service
->replace($config_menu->linkid, [], [
"configuration" => $configuration,
], $bubbleableMetadata);
}
$links[$relevant_link['id']]["options"]["bubleble_metadata"] = $bubbleableMetadata;
}
}