You are here

private function BrowseTokens::coreReplace in Views Token Argument 8

Same name and namespace in other branches
  1. 2.0.x src/BrowseTokens.php \Drupal\views_argument_token\BrowseTokens::coreReplace()

Replace tokens with their values using the core token service.

@todo: update with latest info from token modules.

2 calls to BrowseTokens::coreReplace()
BrowseTokens::contribReplace in src/BrowseTokens.php
Replace tokens with their values using the contributed token module.
BrowseTokens::tokenReplace in src/BrowseTokens.php
Gatekeeper function to direct to either the core or contributed Token.

File

src/BrowseTokens.php, line 93

Class

BrowseTokens
Token handling service. Uses core token service or contributed Token.

Namespace

Drupal\views_argument_token

Code

private function coreReplace($string, $data, $settings = array()) {

  // @TODO: Remove this temp code.
  // This is just here as a way to see all available tokens in debugger.
  $tokens = $this->coreToken
    ->getInfo();
  $options = array(
    'clear' => TRUE,
  );

  // Replace tokens with core Token service.
  $replaced = $this->coreToken
    ->replace($string, $data, $options);

  // Ensure that there are no double-slash sequences due to empty token
  // values.
  $replaced = preg_replace('/(?<!:)\\/+\\//', '/', $replaced);
  return $replaced;
}