public function ContentTranslationHandler::entityFormSubmit in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormSubmit()
- 9 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormSubmit()
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.
File
- core/
modules/ content_translation/ src/ ContentTranslationHandler.php, line 720
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translationCode
public function entityFormSubmit($form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
$form_object = $form_state
->getFormObject();
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $form_object
->getEntity();
// ContentEntityForm::submit will update the changed timestamp on submit
// after the entity has been validated, so that it does not break the
// EntityChanged constraint validator. The content translation metadata
// field for the changed timestamp does not have such a constraint defined
// at the moment, but it is correct to update its value in a submission
// handler as well and have the same logic like in the Form API.
if ($entity
->hasField('content_translation_changed')) {
$metadata = $this->manager
->getTranslationMetadata($entity);
$metadata
->setChangedTime(REQUEST_TIME);
}
}