function _potx_parse_shipped_configuration in Translation template extractor 7.3
Same name and namespace in other branches
- 8 potx.inc \_potx_parse_shipped_configuration()
- 6.3 potx.inc \_potx_parse_shipped_configuration()
- 7.2 potx.inc \_potx_parse_shipped_configuration()
Parse shipped configuration for translatables. Drupal 8+
Parameters
string $save_callback:
string $api_version:
2 calls to _potx_parse_shipped_configuration()
- PotxTestCase::testDrupal8ShippedConfiguration in tests/
potx.test - Test parsing of Drupal 8 shipped configuration files.
- potx_finish_processing in ./
potx.inc - Executes tasks that need to happen after all the files have been processed.
File
- ./
potx.inc, line 2533 - Extraction API used by the web and command line interface.
Code
function _potx_parse_shipped_configuration($save_callback = '_potx_save_string', $api_version = POTX_API_CURRENT) {
global $_potx_module_metadata;
global $_potx_processed_schema;
global $_potx_processed_modules;
global $potx_callbacks;
foreach ($_potx_module_metadata as $module_name => $module_metadata) {
// Reset the processed schema for every module.
$_potx_processed_modules = array();
$_potx_processed_schema = array(
'translatables' => array(),
'types' => array(),
'mappings' => array(),
'contexts' => array(),
);
// "core" contains the base data type and translatable definitions.
_potx_process_module_schemas(array(
'core',
));
_potx_process_module_schemas(array(
$module_name,
));
if (isset($module_metadata['config']['install'])) {
foreach ($module_metadata['config']['install'] as $config_paths) {
$parsed_config = _potx_parse_yaml($config_paths[1]);
if ($parsed_config === NULL) {
continue;
}
// Dependencies defined in a config file itself should not be visible
// to other config files. So, make a temp copy here, and revert after
// parsing the config file.
$temp = $_potx_processed_schema;
if (isset($parsed_config['dependencies']['module'])) {
_potx_process_module_schemas($parsed_config['dependencies']['module']);
}
// Find the schema that matches the config file.
$path_info = pathinfo($config_paths[1]);
$config_name = $path_info['filename'];
$schema = _potx_find_matching_schema($config_name);
if ($schema !== NULL) {
_potx_find_shipped_config_translatables($parsed_config, $schema, NULL, NULL, $config_paths[0], $save_callback);
}
$_potx_processed_schema = $temp;
}
}
if (isset($module_metadata['config']['optional'])) {
// Optional configs are different, since they do not explicitly specify
// which module they belong to.
foreach ($module_metadata['config']['optional'] as $config_paths) {
$_potx_processed_modules = array();
$_potx_processed_schema = array(
'translatables' => array(),
'types' => array(),
'mappings' => array(),
'contexts' => array(),
);
_potx_process_module_schemas(array(
'core',
));
// Find the schema that matches the config file.
$path_info = pathinfo($config_paths[1]);
$config_name = $path_info['filename'];
$parsed_config = _potx_parse_yaml($config_paths[1]);
if ($parsed_config === NULL) {
continue;
}
$match_candidates = _potx_find_matching_schema_candidates($config_name);
$matched = $potx_callbacks['schema_reverse_lookup']($match_candidates);
if ($matched === NULL) {
continue;
}
_potx_process_module_schemas(array(
$matched,
));
if (isset($parsed_config['dependencies']['module'])) {
_potx_process_module_schemas($parsed_config['dependencies']['module']);
}
$schema = _potx_find_matching_schema($config_name);
_potx_find_shipped_config_translatables($parsed_config, $schema, NULL, NULL, $config_paths[0], $save_callback);
}
}
}
}