Issue #3240174 by alexpott, andypost, daffie: \Drupal\config_translation\FormElement\Textarea() can cause deprecations on PHP 8.1

merge-requests/1289/head
catch 2021-10-04 15:59:45 +01:00
parent 3fc999a87f
commit 2145374d1e
1 changed files with 6 additions and 4 deletions

View File

@ -14,13 +14,15 @@ class Textarea extends FormElementBase {
*/
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
// Estimate a comfortable size of the input textarea.
$rows_words = ceil(str_word_count($translation_config) / 5);
$rows_newlines = substr_count($translation_config, "\n") + 1;
$rows = max($rows_words, $rows_newlines);
if (is_string($translation_config)) {
$rows_words = ceil(str_word_count($translation_config) / 5);
$rows_newlines = substr_count($translation_config, "\n") + 1;
$rows = max($rows_words, $rows_newlines);
}
return [
'#type' => 'textarea',
'#rows' => $rows,
'#rows' => $rows ?? 1,
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
}