You are here

function _potx_config_replace_name in Translation template extractor 8

Same name and namespace in other branches
  1. 6.3 potx.inc \_potx_config_replace_name()
  2. 7.3 potx.inc \_potx_config_replace_name()
  3. 7.2 potx.inc \_potx_config_replace_name()

Replaces variables in configuration name.

The configuration name may contain one or more variables to be replaced, enclosed in square brackets like '[name]' and will follow the replacement rules defined by the _potx_replace_variable() function.

Based on Drupal\Core\Config\TypedConfigManager::replaceName($name, $data)

Parameters

string $name: Configuration name with variables in square brackets.

mixed $config_data: Configuration data for the element.

Return value

string Configuration name with variables replaced.

1 call to _potx_config_replace_name()
_potx_find_shipped_config_translatables in ./potx.inc
Recursively check elements in shipped config with the processed schema.

File

./potx.inc, line 2708
Extraction API used by the web and command line interface.

Code

function _potx_config_replace_name($name, $config_data) {
  if (preg_match_all("/\\[(.*)\\]/U", $name, $matches)) {

    // Build our list of '[value]' => replacement.
    $replace = [];
    foreach (array_combine($matches[0], $matches[1]) as $key => $value) {
      $replace[$key] = _potx_replace_variable($value, $config_data);
    }
    return strtr($name, $replace);
  }
  else {
    return $name;
  }
}