You are here

function _potx_load_module_metadata in Translation template extractor 7.3

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

Load a module's metadata, including its dependencies and list of config schema files.

Parameters

string $module_name: The module's name.

Return value

bool TRUE if the module was found, FALSE otherwise.

1 string reference to '_potx_load_module_metadata'
potx_local_init in ./potx.local.inc
Initialize potx to run locally, e.g. by drush.

File

./potx.local.inc, line 219

Code

function _potx_load_module_metadata($module_name) {
  global $_potx_found_modules;
  global $_potx_module_metadata;
  if (!isset($_potx_found_modules[$module_name])) {
    return FALSE;
  }
  $module_path = $_potx_found_modules[$module_name]['path'];
  if ($module_name === 'core') {
    $_potx_module_metadata['core']['dependencies'] = array();
  }
  else {
    $info_path = $module_path . '/' . $module_name . '.info.yml';
    $code = file_get_contents($info_path);
    try {
      $info_yaml = Yaml::parse($code);
      $_potx_module_metadata[$module_name]['dependencies'] = isset($info_yaml['dependencies']) ? $info_yaml['dependencies'] : array();
    } catch (ParseException $e) {
      watchdog('potx', "YAML parseing error on file @path: @error", array(
        '@path' => $file_path,
        '@error' => $e
          ->getMessage(),
      ));
      return FALSE;
    }
  }
  $module_files = _potx_explore_dir($module_path . '/config/schema/', '*', POTX_API_8);
  foreach ($module_files as $file_path) {
    if (preg_match('~config/schema/[^/]+\\.yml$~', $file_path)) {
      $_potx_module_metadata[$module_name]['config']['schema'][] = array(
        NULL,
        $file_path,
      );
    }
  }
  return TRUE;
}