Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291555

token_replace in Drupal 8

$
0
0

Hello!
How can i use token_replace() in Drupal 8? There is Token class in Drupal\Core\Utility\Token.

Code for D7 + Token module:

<?php
$filename
= token_replace($filename);
?>

Code for D8:

<?php
  $handler
= new Drupal\Core\Extension\ModuleHandler(array('module_name'));
 
$token = new Drupal\Core\Utility\Token($handler);
 
$filename = $token->replace($filename);
?>

Is it right way?


Viewing all articles
Browse latest Browse all 291555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>