You are here

function _potx_find_matching_schema in Translation template extractor 6.3

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

Find the schema element matching with a specific type.

Based on Drupal\Core\Config\TypedConfigManager::getFallbackName($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.*

2 calls to _potx_find_matching_schema()
_potx_find_shipped_config_translatables in ./potx.inc
Recursively check elements in shipped configuration with the processed schema.
_potx_parse_shipped_configuration in ./potx.inc
Parse shipped configuration for translatables. Drupal 8+

File

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

Code

function _potx_find_matching_schema($name) {
  global $_potx_processed_schema;
  if (_potx_element_has_schema($name)) {
    return $name;
  }

  // Check for definition of $name with filesystem marker.
  $replaced = preg_replace('/([^.:]+)([.:*]*)$/', '*\\2', $name);
  if ($replaced != $name) {
    if (_potx_element_has_schema($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 && _potx_element_has_schema($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 _potx_find_matching_schema($replaced);
    }
  }
}