function _potx_process_inline_templates in Translation template extractor 6.3
Same name and namespace in other branches
- 8 potx.inc \_potx_process_inline_templates()
- 7.3 potx.inc \_potx_process_inline_templates()
Process Twig inline templates inside PHP files. Drupal 8+
The patterns searched for inline templates include: 1. '#template' => T_CONSTANT_ENCAPSED_STRING 2. ['#template'] = T_CONSTANT_ENCAPSED_STRING
Parameters
$file_name: Name of file parsed.
$save_callback: Callback function used to save strings.
1 call to _potx_process_inline_templates()
- _potx_process_file in ./
potx.inc - Process a file and put extracted information to the given parameters.
File
- ./
potx.inc, line 2549 - Extraction API used by the web and command line interface.
Code
function _potx_process_inline_templates($file_name, $save_callback) {
global $_potx_tokens, $_potx_lookup;
if (!isset($_potx_lookup["'#template'"])) {
return;
}
foreach ($_potx_lookup["'#template'"] as $key => $ti) {
// check for pattern: '#template' => T_CONSTANT_ENCAPSED_STRING
if ($_potx_tokens[$ti + 1][0] == T_DOUBLE_ARROW && $_potx_tokens[$ti + 2][0] == T_CONSTANT_ENCAPSED_STRING) {
$str = $_potx_tokens[$ti + 2][1];
_potx_parse_twig_file($str, $file_name . '::inline-template', $save_callback);
}
elseif ($_potx_tokens[$ti - 1] == '[' && $_potx_tokens[$ti + 1] == ']' && $_potx_tokens[$ti + 2] == '=' && $_potx_tokens[$ti + 3][0] == T_CONSTANT_ENCAPSED_STRING) {
$str = $_potx_tokens[$ti + 3][1];
_potx_parse_twig_file($str, $file_name . '::inline-template', $save_callback);
}
}
}