You are here

function _views_update_8002_token_update in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/views.install \_views_update_8002_token_update()

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 274
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;
}