public function EntityTranslationController::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.

See also

\Drupal\translation_entity\EntityTranslationController::entityFormAlter()

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php, line 348
Definition of Drupal\translation_entity\EntityTranslationController.

Class

EntityTranslationController
Base class for entity translation controllers.

Namespace

Drupal\translation_entity

Code

public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, array &$form_state) {
  $form_controller = translation_entity_form_controller($form_state);
  $form_langcode = $form_controller
    ->getFormLangcode($form_state);
  $source_langcode = $this
    ->getSourceLangcode($form_state);
  if ($source_langcode) {

    // @todo Use the entity setter when all entities support multilingual
    // properties.
    $entity->source[$form_langcode] = $source_langcode;
  }

  // Ensure every key has at least a default value. Subclasses may provide
  // entity-specific values to alter them.
  $values = isset($form_state['values']['translation']) ? $form_state['values']['translation'] : array();
  $entity->retranslate[$form_langcode] = isset($values['translate']) && $values['translate'];
  if (!empty($values['retranslate'])) {
    $this
      ->retranslate($entity, $form_langcode);
  }
}