You are here

public function ContentTranslationHandler::entityFormEntityBuild in Drupal 9

Same name and namespace in other branches
  1. 8 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 679

Class

ContentTranslationHandler
Base class for content translation handlers.

Namespace

Drupal\content_translation

Code

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']) : REQUEST_TIME);
  $metadata
    ->setOutdated(!empty($values['outdated']));
  if (!empty($values['retranslate'])) {
    $this
      ->retranslate($entity, $form_langcode);
  }
}