4a5,12
>  * Definition of Drupal\Core\Utility\Token.
>  */
> 
> namespace Drupal\Core\Utility;
> 
> use Drupal\Core\Extension\ModuleHandlerInterface;
> 
> /**
13c21
<  * the token_replace() function, passing in the text. The token system will
---
>  * the Token::replace() function, passing in the text. The token system will
34c42
<  * return token_replace($text, $data);
---
>  * return Token::replace($text, $data);
43c51
<  * @see token_replace()
---
>  * @see Token::replace()
46a55,83
> class Token {
> 
>   /**
>    * Token definitions.
>    *
>    * @var array|null
>    *   An array of token definitions, or NULL when the definitions are not set.
>    *
>    * @see self::setInfo()
>    * @see self::getInfo()
>    * @see self::resetInfo()
>    */
>   protected $tokenInfo;
> 
>   /**
>    * The module handler service.
>    *
>    * @var \Drupal\Core\Extension\ModuleHandlerInterface
>    */
>   protected $moduleHandler;
> 
>   /**
>    * Constructor.
>    *
>    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
>    */
>   public function __construct(ModuleHandlerInterface $module_handler) {
>     $this->moduleHandler = $module_handler;
>   }
80,81c117,118
< function token_replace($text, array $data = array(), array $options = array()) {
<   $text_tokens = token_scan($text);
---
>   public function replace($text, array $data = array(), array $options = array()) {
>     $text_tokens = $this->scan($text);
88c125
<     $replacements += token_generate($type, $tokens, $data, $options);
---
>       $replacements += $this->generate($type, $tokens, $data, $options);
115c152
< function token_scan($text) {
---
>   public function scan($text) {
177c214
< function token_generate($type, array $tokens, array $data = array(), array $options = array()) {
---
>   public function generate($type, array $tokens, array $data = array(), array $options = array()) {
179c216
<   $replacements = module_invoke_all('tokens', $type, $tokens, $data, $options);
---
>     $replacements = $this->moduleHandler->invokeAll('tokens', array($type, $tokens, $data, $options));
188c225
<   drupal_alter('tokens', $replacements, $context);
---
>     $this->moduleHandler->alter('tokens', $replacements, $context);
204c241
<  *   $results = token_find_with_prefix($data, 'author');
---
>    *   $results = Token::findWithPrefix($data, 'author');
220c257
< function token_find_with_prefix(array $tokens, $prefix, $delimiter = ':') {
---
>   public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') {
238,254d274
<  * For example:
<  * @code
<  *   $data['types']['node'] = array(
<  *     'name' => t('Nodes'),
<  *     'description' => t('Tokens related to node objects.'),
<  *   );
<  *   $data['tokens']['node']['title'] = array(
<  *     'name' => t('Title'),
<  *     'description' => t('The title of the current node.'),
<  *   );
<  *   $data['tokens']['node']['author'] = array(
<  *     'name' => t('Author'),
<  *     'description' => t('The author of the current node.'),
<  *     'type' => 'user',
<  *   );
<  * @endcode
<  *
256c276,304
<  *   An associative array of token information, grouped by token type.
---
>    *   An associative array of token information, grouped by token type. The
>    *   array structure is identical to that of hook_token_info().
>    *
>    * @see hook_token_info()
>    */
>   public function getInfo() {
>     if (is_null($this->tokenInfo)) {
>       $this->tokenInfo = $this->moduleHandler->invokeAll('token_info');
>       $this->moduleHandler->alter('token_info', $this->tokenInfo);
>     }
> 
>     return $this->tokenInfo;
>   }
> 
>   /**
>    * Sets metadata describing supported tokens.
>    *
>    * @param array $tokens
>    *   Token metadata that has an identical structure to the return value of
>    *   hook_token_info().
>    *
>    * @see hook_token_info()
>    */
>   public function setInfo(array $tokens) {
>     $this->tokenInfo = $tokens;
>   }
> 
>   /**
>    * Resets metadata describing supported tokens.
258,262c306,307
< function token_info() {
<   $data = &drupal_static(__FUNCTION__);
<   if (!isset($data)) {
<     $data = module_invoke_all('token_info');
<     drupal_alter('token_info', $data);
---
>   public function resetInfo() {
>     $this->tokenInfo = NULL;
264d308
<   return $data;
