Entity builder method.
string $entity_type: The type of the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity whose form is being built.
\Drupal\translation_entity\EntityTranslationController::entityFormAlter()
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);
if (!isset($entity->translation[$form_langcode])) {
$entity->translation[$form_langcode] = array();
}
$values = isset($form_state['values']['translation_entity']) ? $form_state['values']['translation_entity'] : array();
$translation =& $entity->translation[$form_langcode];
// @todo Use the entity setter when all entities support multilingual
// properties.
$translation['uid'] = !empty($values['name']) && ($account = user_load_by_name($values['name'])) ? $account->uid : 0;
$translation['status'] = !empty($values['status']);
$translation['created'] = !empty($values['created']) ? strtotime($values['created']) : REQUEST_TIME;
$translation['changed'] = REQUEST_TIME;
$source_langcode = $this
->getSourceLangcode($form_state);
if ($source_langcode) {
$translation['source'] = $source_langcode;
}
$translation['outdated'] = !empty($values['outdated']);
if (!empty($values['retranslate'])) {
$this
->retranslate($entity, $form_langcode);
}
// Set contextual information that can be reused during the storage phase.
// @todo Remove this once we have an EntityLanguageDecorator to deal with
// the active language.
$attributes = drupal_container()
->get('request')->attributes;
$attributes
->set('working_langcode', $form_langcode);
$attributes
->set('source_langcode', $source_langcode);
}