function NodeTranslationHandler::entityFormEntityBuild

Same name in other branches
  1. 9 core/modules/node/src/NodeTranslationHandler.php \Drupal\node\NodeTranslationHandler::entityFormEntityBuild()
  2. 8.9.x core/modules/node/src/NodeTranslationHandler.php \Drupal\node\NodeTranslationHandler::entityFormEntityBuild()
  3. 11.x core/modules/node/src/NodeTranslationHandler.php \Drupal\node\NodeTranslationHandler::entityFormEntityBuild()

Overrides ContentTranslationHandler::entityFormEntityBuild

File

core/modules/node/src/NodeTranslationHandler.php, line 60

Class

NodeTranslationHandler
Defines the translation handler for nodes.

Namespace

Drupal\node

Code

public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
    if ($form_state->hasValue('content_translation')) {
        $translation =& $form_state->getValue('content_translation');
        $translation['status'] = $entity->isPublished();
        $account = $entity->uid->entity;
        $translation['uid'] = $account ? $account->id() : 0;
        $translation['created'] = $this->dateFormatter
            ->format($entity->created->value, 'custom', 'Y-m-d H:i:s O');
    }
    parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.