function ContentTranslationHandler::entityFormEntityBuild
Same name in other branches
- 9 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormEntityBuild()
- 8.9.x core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormEntityBuild()
- 10 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::entityFormEntityBuild()
Entity builder method.
Parameters
string $entity_type: The type of the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity whose form is being built.
array $form: A nested array form elements comprising the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
See also
\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
3 calls to ContentTranslationHandler::entityFormEntityBuild()
- CommentTranslationHandler::entityFormEntityBuild in core/
modules/ comment/ src/ CommentTranslationHandler.php - Entity builder method.
- NodeTranslationHandler::entityFormEntityBuild in core/
modules/ node/ src/ NodeTranslationHandler.php - Entity builder method.
- TermTranslationHandler::entityFormEntityBuild in core/
modules/ taxonomy/ src/ TermTranslationHandler.php - Entity builder method.
3 methods override ContentTranslationHandler::entityFormEntityBuild()
- CommentTranslationHandler::entityFormEntityBuild in core/
modules/ comment/ src/ CommentTranslationHandler.php - Entity builder method.
- NodeTranslationHandler::entityFormEntityBuild in core/
modules/ node/ src/ NodeTranslationHandler.php - Entity builder method.
- TermTranslationHandler::entityFormEntityBuild in core/
modules/ taxonomy/ src/ TermTranslationHandler.php - Entity builder method.
File
-
core/
modules/ content_translation/ src/ ContentTranslationHandler.php, line 656
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translationCode
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
$form_object = $form_state->getFormObject();
$form_langcode = $form_object->getFormLangcode($form_state);
$values =& $form_state->getValue('content_translation', []);
$metadata = $this->manager
->getTranslationMetadata($entity);
$metadata->setAuthor(!empty($values['uid']) ? User::load($values['uid']) : User::load(0));
$metadata->setPublished(!empty($values['status']));
$metadata->setCreatedTime(!empty($values['created']) ? strtotime($values['created']) : $this->time
->getRequestTime());
$metadata->setOutdated(!empty($values['outdated']));
if (!empty($values['retranslate'])) {
$this->retranslate($entity, $form_langcode);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.