/** * Overrides \Drupal\Core\Entity\EntityForm::prepareEntity(). * * Prepares the custom entity object. */ protected function prepareEntity() { parent::prepareEntity(); /** @var EntityTypeBaseInterface $entity_type */ $entity_type = $this->entity->type->referencedEntities()[0]; // Set up default values, if required. if (!$this->entity->isNew()) { $this->entity->setRevisionLog(NULL); } // Always use the default revision setting. $this->entity->setNewRevision($entity_type->shouldCreateNewRevision()); }
/** * {@inheritdoc} */ protected function prepareEntity() { parent::prepareEntity(); $bundle_entity = $this->getBundleEntity(); // Set up default values, if required. if (!$this->entity->isNew()) { $this->entity->setRevisionLogMessage(NULL); } if ($bundle_entity instanceof RevisionableEntityBundleInterface) { // Always use the default revision setting. $this->entity->setNewRevision($bundle_entity && $bundle_entity->shouldCreateNewRevision()); } }