TypedConfigManager::getFallbackName

protected TypedConfigManager::getFallbackName($name)

Gets fallback configuration schema name.

Parameters

string $name: Configuration name or key.

Return value

null|string The resolved schema name for the given configuration name or key. Returns null if there is no schema name to fallback to. For example, breakpoint.breakpoint.module.toolbar.narrow will check for definitions in the following order: breakpoint.breakpoint.module.toolbar.* breakpoint.breakpoint.module.*.* breakpoint.breakpoint.module.* breakpoint.breakpoint.*.*.* breakpoint.breakpoint.* breakpoint.*.*.*.* breakpoint.* Colons are also used, for example, block.settings.system_menu_block:footer will check for definitions in the following order: block.settings.system_menu_block:* block.settings.*:* block.settings.* block.*.*:* block.*

File

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

Class

TypedConfigManager
Manages config schema type plugins.

Namespace

Drupal\Core\Config

Code

protected function getFallbackName($name) {
  // Check for definition of $name with filesystem marker.
  $replaced = preg_replace('/([^\.:]+)([\.:\*]*)$/', '*\2', $name);
  if ($replaced != $name) {
    if (isset($this->definitions[$replaced])) {
      return $replaced;
    }
    else {
      // No definition for this level. Collapse multiple wildcards to a single
      // wildcard to see if there is a greedy match. For example,
      // breakpoint.breakpoint.*.* becomes
      // breakpoint.breakpoint.*
      $one_star = preg_replace('/\.([:\.\*]*)$/', '.*', $replaced);
      if ($one_star != $replaced && isset($this->definitions[$one_star])) {
        return $one_star;
      }
      // Check for next level. For example, if breakpoint.breakpoint.* has
      // been checked and no match found then check breakpoint.*.*
      return $this->getFallbackName($replaced);
    }
  }
}
doc_Drupal
2016-10-29 09:49:55
Comments
Leave a Comment

Please login to continue.