W3cubDocs

/Drupal 8

protected function TypedConfigManager::replaceName

protected TypedConfigManager::replaceName($name, $data)

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 replaceVariable() method.

Parameters

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

mixed $data: Configuration data for the element.

Return value

string Configuration name with variables replaced.

File

core/lib/Drupal/Core/Config/TypedConfigManager.php, line 265

Class

TypedConfigManager
Manages config schema type plugins.

Namespace

Drupal\Core\Config

Code

protected function replaceName($name, $data) {
  if (preg_match_all("/\[(.*)\]/U", $name, $matches)) {
    // Build our list of '[value]' => replacement.
    $replace = array();
    foreach (array_combine($matches[0], $matches[1]) as $key => $value) {
      $replace[$key] = $this->replaceVariable($value, $data);
    }
    return strtr($name, $replace);
  }
  else {
    return $name;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!TypedConfigManager.php/function/TypedConfigManager::replaceName/8.1.x