public function ProductBundleTranslationHandler::entityFormEntityBuild in Commerce Product Bundle 8
Entity builder method.
Parameters
string $entity_type: The type of the entity.
\Drupal\Core\Entity\EntityInterface $entity: The entity whose form is being built.
Overrides ContentTranslationHandler::entityFormEntityBuild
See also
\Drupal\content_translation\ContentTranslationHandler::entityFormAlter()
File
- src/
ProductBundleTranslationHandler.php, line 54
Class
- ProductBundleTranslationHandler
- Defines the translation handler for products bundles.
Namespace
Drupal\commerce_product_bundleCode
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
/** @var \Drupal\commerce_product_bundle\Entity\BundleInterface $entity */
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'] = \Drupal::service('date.formatter')
->format($entity->created->value, 'custom', 'Y-m-d H:i:s O');
}
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}