public function ContentTranslationHandler::entityFormEntityBuild in Zircon Profile 8.0
Same name and namespace in other branches
- 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.
See also
\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
2 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.
2 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.
File
- core/
modules/ content_translation/ src/ ContentTranslationHandler.php, line 580 - Contains \Drupal\content_translation\ContentTranslationHandler.
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', array());
$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);
$source_langcode = $this
->getSourceLangcode($form_state);
if ($source_langcode) {
$metadata
->setSource($source_langcode);
}
$metadata
->setOutdated(!empty($values['outdated']));
if (!empty($values['retranslate'])) {
$this
->retranslate($entity, $form_langcode);
}
}