diff -u b/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php --- b/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -175,16 +175,6 @@ } /** - * {@inheritdoc} - */ - public function save(array $form, FormStateInterface $form_state) { - parent::save($form, $form_state); - if ($this->showRevisionUi()) { - $this->saveRevisionableFormFields($form, $form_state); - } - } - - /** * Gets the names of all fields edited in the form. * * If the entity form customly adds some fields to the form (i.e. without @@ -432,39 +422,6 @@ } } - /** - * Save revision form fields if the entity enabled the UI. - * - * @param array $form - * An associative array containing the structure of the form. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - public function saveRevisionableFormFields($form, FormStateInterface $form_state) { - $insert = $this->entity->isNew(); - $this->entity->save(); - - $context = ['@type' => $this->entity->bundle(), '%info' => $this->entity->label()]; - $logger = $this->logger($this->entity->getEntityTypeId()); - $bundle_entity = $this->getBundleEntity(); - $t_args = ['@type' => $bundle_entity ? $bundle_entity->label() : $this->entity->getEntityType()->getLabel(), '%label' => $this->entity->label()]; - - if ($insert) { - $logger->notice('@type: added %info.', $context); - drupal_set_message($this->t('@type %label has been created.', $t_args)); - } - else { - $logger->notice('@type: updated %info.', $context); - drupal_set_message($this->t('@type %label has been updated.', $t_args)); - } - - if ($this->entity->getEntityType()->hasLinkTemplate('collection')) { - $form_state->setRedirectUrl($this->entity->toUrl('collection')); - } - else { - $form_state->setRedirectUrl($this->entity->toUrl('canonical')); - } - } /** * Checks whether the revision form fields should be added to the form. diff -u b/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php --- b/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -41,19 +41,37 @@ * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { - $block = $this->entity; - $insert = $block->isNew(); + $insert = $this->entity->isNew(); + $this->entity->save(); + $context = ['@type' => $this->entity->bundle(), '%info' => $this->entity->label()]; + $logger = $this->logger($this->entity->getEntityTypeId()); + $bundle_entity = $this->getBundleEntity(); + $t_args = ['@type' => $bundle_entity ? $bundle_entity->label() : $this->entity->getEntityType()->getLabel(), '%label' => $this->entity->label()]; - parent::save($form, $form_state); + if ($insert) { + $logger->notice('@type: added %info.', $context); + drupal_set_message($this->t('@type %label has been created.', $t_args)); + } + else { + $logger->notice('@type: updated %info.', $context); + drupal_set_message($this->t('@type %label has been updated.', $t_args)); + } + + if ($this->entity->getEntityType()->hasLinkTemplate('collection')) { + $form_state->setRedirectUrl($this->entity->toUrl('collection')); + } + else { + $form_state->setRedirectUrl($this->entity->toUrl('canonical')); + } if ($insert) { - if (!$theme = $block->getTheme()) { + if (!$theme = $this->entity->getTheme()) { $theme = $this->config('system.theme')->get('default'); } $form_state->setRedirect( 'block.admin_add', [ - 'plugin_id' => 'block_content:' . $block->uuid(), + 'plugin_id' => 'block_content:' . $this->entity->uuid(), 'theme' => $theme, ] ); reverted: --- b/core/modules/field/src/Tests/FormTest.php +++ a/core/modules/field/src/Tests/FormTest.php @@ -609,11 +609,11 @@ $this->drupalPostForm(NULL, array(), t('Save')); preg_match('|' . $entity_type . '/manage/(\d+)|', $this->url, $match); $id = $match[1]; + $this->assertText(t('entity_test_rev @id has been created.', array('@id' => $id)), 'Entity was created'); $storage = $this->container->get('entity_type.manager') ->getStorage($entity_type); $entity = $storage->load($id); - $this->assertRaw(t('@type %label has been created.', ['@type' => 'Test entity - revisions', '%label' => $entity->label()])); $this->assertEqual($entity->{$field_name}->value, 99, 'Default value was saved'); // Update the field to remove the default value, and switch to the default @@ -634,7 +634,7 @@ $value = mt_rand(1, 127); $edit = array("{$field_name}[0][value]" => $value); $this->drupalPostForm(NULL, $edit, t('Save')); + $this->assertText(t('entity_test_rev @id has been updated.', array('@id' => $id)), 'Entity was updated'); - $this->assertRaw(t('@type %label has been updated.', ['@type' => 'Test entity - revisions', '%label' => $entity->label()])); $storage->resetCache([$id]); $entity = $storage->load($id); $this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated'); diff -u b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php --- b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulRev.php @@ -12,7 +12,7 @@ * "view_builder" = "Drupal\entity_test\EntityTestViewBuilder", * "access" = "Drupal\entity_test\EntityTestAccessControlHandler", * "form" = { - * "default" = "Drupal\entity_test\EntityTestRevisionForm", + * "default" = "Drupal\entity_test\EntityTestForm", * "delete" = "Drupal\entity_test\EntityTestDeleteForm" * }, * "translation" = "Drupal\content_translation\ContentTranslationHandler", @@ -27,6 +27,7 @@ * revision_data_table = "entity_test_mulrev_property_revision", * admin_permission = "administer entity_test content", * translatable = TRUE, + * show_revision_ui = TRUE, * entity_keys = { * "id" = "id", * "uuid" = "uuid", diff -u b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php --- b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestRev.php @@ -17,7 +17,7 @@ * "access" = "Drupal\entity_test\EntityTestAccessControlHandler", * "view_builder" = "Drupal\entity_test\EntityTestViewBuilder", * "form" = { - * "default" = "\Drupal\entity_test\EntityTestRevisionForm", + * "default" = "Drupal\entity_test\EntityTestForm", * "delete" = "Drupal\entity_test\EntityTestDeleteForm" * }, * "view_builder" = "Drupal\entity_test\EntityTestViewBuilder", @@ -30,6 +30,7 @@ * base_table = "entity_test_rev", * revision_table = "entity_test_rev_revision", * admin_permission = "administer entity_test content", + * show_revision_ui = TRUE, * entity_keys = { * "id" = "id", * "uuid" = "uuid", reverted: --- b/core/modules/system/tests/modules/entity_test/src/EntityTestRevisionForm.php +++ /dev/null @@ -1,38 +0,0 @@ -entity->name->value)) { - // Assign a random name to new EntityTest entities, to avoid repetition in - // tests. - $random = new Random(); - $this->entity->name->value = $random->name(); - } - } - - /** - * {@inheritdoc} - */ - public function save(array $form, FormStateInterface $form_state) { - try { - parent::save($form, $form_state); - } - catch (\Exception $e) { - \Drupal::state()->set('entity_test.form.save.exception', get_class($e) . ': ' . $e->getMessage()); - } - } - -}