Skip to content
Snippets Groups Projects

Issue #3194027: Generate URL instead of just alias for :url token

1 file
+ 2
3
Compare changes
  • Side-by-side
  • Inline
@@ -10,6 +10,7 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
/**
* Implements hook_help().
@@ -159,8 +160,6 @@ function node_keep_token_tokens($type, $tokens, array $data, array $options, Bub
$replacements = [];
if ($type == 'node-keep') {
/** @var \Drupal\path_alias\AliasManager $manager */
$manager = \Drupal::service('path_alias.manager');
/** @var \Drupal\node_keep_token\NodeKeepTokenService $keeper_helper */
$keeper_helper = \Drupal::service('node_keep_token.helper');
$machine_names = $keeper_helper->getProtectedMachineNames();
@@ -168,7 +167,7 @@ function node_keep_token_tokens($type, $tokens, array $data, array $options, Bub
if (in_array(str_replace(':url', '', $name), array_keys($machine_names))) {
$base_name = str_replace(':url', '', $name);
$nid = $machine_names[$base_name]['id'];
$replacements[$original] = $manager->getAliasByPath('/node/' . $nid);
$replacements[$original] = Url::fromRoute('entity.node.canonical', ['node' => $nid])->toString();
}
elseif (in_array(str_replace(':uri', '', $name), array_keys($machine_names))) {
$base_name = str_replace(':uri', '', $name);
Loading