You are here

function _potx_build_reverse_lookup in Translation template extractor 7.3

Same name and namespace in other branches
  1. 8 potx.local.inc \_potx_build_reverse_lookup()

Build the reverse lookup table from config schemas' matching keys, and their containing modules, for all modules found locally.

This is only used on a local potx. Building the reverse lookup table is expensive, so it is delayed as much as possible, i.e. until an optional config is parsed, and the reverse lookup is called.

See also

_potx_find_all_modules()

_potx_schema_reverse_lookup()

1 call to _potx_build_reverse_lookup()
_potx_schema_reverse_lookup in ./potx.local.inc
Find the module containing the schema for a specific config file, based on its matching candidates, using a reverse lookup table.

File

./potx.local.inc, line 177

Code

function _potx_build_reverse_lookup() {
  global $_potx_reverse_lookup_built;
  global $_potx_found_modules;
  global $potx_callbacks;
  foreach ($_potx_found_modules as $module_name => $module_data) {
    $module_files = _potx_explore_dir($module_data['path'] . '/', '*', POTX_API_8);
    foreach ($module_files as $file_name) {
      if (preg_match('~config/schema/[^/]+\\.yml$~', $file_name)) {
        $code = file_get_contents($file_name);
        try {
          $yaml = Yaml::parse($code);
          $keys = array_keys($yaml);
          $potx_callbacks['schema_store_lookup']($keys, $module_name);
        } catch (ParseException $e) {
          watchdog('potx', "YAML parseing error on file @path: @error", array(
            '@path' => $file_path,
            '@error' => $e
              ->getMessage(),
          ));
        }
      }
    }
  }
  $_potx_reverse_lookup_built = TRUE;
}