You are here

function _potx_parse_yaml in Translation template extractor 8

Same name and namespace in other branches
  1. 7.3 potx.inc \_potx_parse_yaml()

Helper function for parsing yaml files.

Parameters

string $yaml_path: Path to the yaml file.

Return value

array The parsed yaml, if it contains valid yaml. NULL if it's invalid or empty.

3 calls to _potx_parse_yaml()
_potx_load_yaml_translation_patterns in ./potx.inc
Load the list of YAML translation patterns from a file.
_potx_parse_shipped_configuration in ./potx.inc
Parse shipped configuration for translatables. Drupal 8+.
_potx_process_module_schemas in ./potx.inc
Recursively process and merge the schema required for parsing shipped config.

File

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

Code

function _potx_parse_yaml($yaml_path) {
  try {
    $code = file_get_contents($yaml_path);
    $yaml = Yaml::parse($code);
    return $yaml;
  } catch (ParseException $e) {
    potx_status('error', t("YAML parsing error on file @path: @error", [
      '@path' => $yaml_path,
      '@error' => $e
        ->getMessage(),
    ]), $yaml_path);
  }
  return NULL;
}