You are here

function _views_update_8002_token_update in Drupal 8

Updates a views configuration string from using %/! to twig tokens.

Parameters

string $text: Text in which to search for argument tokens and replace them with their twig representation.

array $argument_map: A map of argument machine names keyed by their previous index.

Return value

string The updated token.

1 call to _views_update_8002_token_update()
views_update_8002 in core/modules/views/views.install
Updates %1 and !1 tokens to argument tokens.

File

core/modules/views/views.install, line 269
Contains install and update functions for Views.

Code

function _views_update_8002_token_update($text, array $argument_map) {
  $text = preg_replace_callback('/%(\\d)/', function ($match) use ($argument_map) {
    return "{{ arguments.{$argument_map[$match[1]]} }}";
  }, $text);
  $text = preg_replace_callback('/!(\\d)/', function ($match) use ($argument_map) {
    return "{{ raw_arguments.{$argument_map[$match[1]]} }}";
  }, $text);
  return $text;
}