entityFormEntityBuild example


  }

  /** * {@inheritdoc} */
  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();
    }
    parent::entityFormEntityBuild($entity_type$entity$form$form_state);
  }

}
/** * {@inheritdoc} */
  public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state) {
    if ($form_state->hasValue('content_translation')) {
      $translation = &$form_state->getValue('content_translation');
      /** @var \Drupal\comment\CommentInterface $entity */
      $translation['status'] = $entity->isPublished();
      $translation['name'] = $entity->getAuthorName();
    }
    parent::entityFormEntityBuild($entity_type$entity$form$form_state);
  }

}
/** * {@inheritdoc} */
  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);
  }

}
Home | Imprint | This part of the site doesn't use cookies.