function ContentEntityForm::buildEntity
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()
- 10 core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()
- 8.9.x core/lib/Drupal/Core/Entity/ContentEntityForm.php \Drupal\Core\Entity\ContentEntityForm::buildEntity()
1 method overrides ContentEntityForm::buildEntity()
- CommentForm::buildEntity in core/
modules/ comment/ src/ CommentForm.php - Builds an updated entity object based upon the submitted form values.
File
-
core/
lib/ Drupal/ Core/ Entity/ ContentEntityForm.php, line 153
Class
- ContentEntityForm
- Entity form variant for content entity types.
Namespace
Drupal\Core\EntityCode
public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = parent::buildEntity($form, $form_state);
// Mark the entity as requiring validation.
$entity->setValidationRequired(!$form_state->getTemporaryValue('entity_validated'));
// Save as a new revision if requested to do so.
if ($this->showRevisionUi() && !$form_state->isValueEmpty('revision')) {
$entity->setNewRevision();
if ($entity instanceof RevisionLogInterface) {
// If a new revision is created, save the current user as
// revision author.
$entity->setRevisionUserId($this->currentUser()
->id());
$entity->setRevisionCreationTime($this->time
->getRequestTime());
}
}
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.