/**
* Form validation handler for ContentTranslationHandler::entityFormAlter().
*
* Validates the submitted content translation metadata.
*/
public function entityFormValidate($form, FormStateInterface
$form_state) { if (!
$form_state->
isValueEmpty('content_translation'
)) { $translation =
$form_state->
getValue('content_translation'
);
// Validate the "authored by" field.
if (!
empty($translation['uid'
]) && !
($account = User::
load($translation['uid'
]))) { $form_state->
setErrorByName('content_translation][uid',
t('The translation authoring username %name does not exist.',
['%name' =>
$account->
getAccountName()]));
} // Validate the "authored on" field.
if (!
empty($translation['created'
]) &&
strtotime($translation['created'
]) === FALSE
) { $form_state->
setErrorByName('content_translation][created',
t('You have to specify a valid translation authoring date.'
));
} } } /**
* Form submission handler for ContentTranslationHandler::entityFormAlter().
*
* Updates metadata fields, which should be updated only after the validation
* has run and before the entity is saved.
*/