protected function DefaultFieldProcessor::handleFormat in Translation Management Tool 8
Handles adjusting the field item data if a format was detected.
Parameters
string $format: The text format.
array $data: The extracted field data.
int $delta: The field item delta.
Return value
array The adjusted field data.
1 call to DefaultFieldProcessor::handleFormat()
- DefaultFieldProcessor::extractTranslatableData in sources/
content/ src/ DefaultFieldProcessor.php - Extracts the translatatable data structure from the given field.
File
- sources/
content/ src/ DefaultFieldProcessor.php, line 139
Class
- DefaultFieldProcessor
- Default field processor.
Namespace
Drupal\tmgmt_contentCode
protected function handleFormat($format, $data, $delta) {
$allowed_formats = (array) \Drupal::config('tmgmt.settings')
->get('allowed_formats');
if ($allowed_formats && array_search($format, $allowed_formats) === FALSE) {
// There are allowed formats and this one is not part of them,
// explicitly mark all data as untranslatable.
foreach ($data[$delta] as $name => $value) {
if (is_array($value) && isset($value['#translate'])) {
$data[$delta][$name]['#translate'] = FALSE;
}
}
}
else {
// Add the format to the translatable properties.
foreach ($data[$delta] as $name => $value) {
if (is_array($value) && isset($value['#translate']) && $value['#translate'] == TRUE) {
$data[$delta][$name]['#format'] = $format;
}
}
}
return $data;
}