You are here

protected function TypedConfigManager::getFallbackName in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/TypedConfigManager.php \Drupal\Core\Config\TypedConfigManager::getFallbackName()

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.*

1 call to TypedConfigManager::getFallbackName()
TypedConfigManager::getDefinition in core/lib/Drupal/Core/Config/TypedConfigManager.php
Gets a specific plugin definition.

File

core/lib/Drupal/Core/Config/TypedConfigManager.php, line 188
Contains \Drupal\Core\Config\TypedConfigManager.

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