Skip to content
Snippets Groups Projects
Commit 8018260c authored by Daniel Wehner's avatar Daniel Wehner
Browse files

Expand the tests a bit to use the new base form class

parent 0bf0d39a
No related branches found
No related tags found
No related merge requests found
...@@ -138,7 +138,13 @@ class ContentEntityFormWithRevisions extends ContentEntityForm { ...@@ -138,7 +138,13 @@ class ContentEntityFormWithRevisions extends ContentEntityForm {
if ($this->entity->id()) { if ($this->entity->id()) {
$form_state->setValue('id', $this->entity->id()); $form_state->setValue('id', $this->entity->id());
$form_state->set('id', $this->entity->id()); $form_state->set('id', $this->entity->id());
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
if ($this->entity->getEntityType()->hasLinkTemplate('collection')) {
$form_state->setRedirectUrl($this->entity->toUrl('collection'));
}
else {
$form_state->setRedirectUrl($this->entity->toUrl('canonical'));
}
} }
else { else {
// In the unlikely case something went wrong on save, the entity will be // In the unlikely case something went wrong on save, the entity will be
......
...@@ -11,3 +11,6 @@ entity_module_test.entity_test_enhanced_bundle.*: ...@@ -11,3 +11,6 @@ entity_module_test.entity_test_enhanced_bundle.*:
description: description:
type: text type: text
label: 'Description' label: 'Description'
new_revision:
type: boolean
label: 'New revision'
...@@ -22,8 +22,8 @@ use Drupal\entity\Revision\EntityRevisionLogTrait; ...@@ -22,8 +22,8 @@ use Drupal\entity\Revision\EntityRevisionLogTrait;
* handlers = { * handlers = {
* "storage" = "\Drupal\Core\Entity\Sql\SqlContentEntityStorage", * "storage" = "\Drupal\Core\Entity\Sql\SqlContentEntityStorage",
* "form" = { * "form" = {
* "add" = "\Drupal\Core\Entity\ContentEntityForm", * "add" = "\Drupal\entity\Form\ContentEntityFormWithRevisions",
* "edit" = "\Drupal\Core\Entity\ContentEntityForm", * "edit" = "\Drupal\entity\Form\ContentEntityFormWithRevisions",
* "delete" = "\Drupal\Core\Entity\EntityDeleteForm", * "delete" = "\Drupal\Core\Entity\EntityDeleteForm",
* }, * },
* "route_provider" = { * "route_provider" = {
......
...@@ -9,6 +9,7 @@ namespace Drupal\entity_module_test\Entity; ...@@ -9,6 +9,7 @@ namespace Drupal\entity_module_test\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\entity\Entity\EntityDescriptionInterface; use Drupal\entity\Entity\EntityDescriptionInterface;
use Drupal\entity\Entity\RevisionableEntityBundleInterface;
/** /**
* Provides bundles for the test entity. * Provides bundles for the test entity.
...@@ -38,7 +39,7 @@ use Drupal\entity\Entity\EntityDescriptionInterface; ...@@ -38,7 +39,7 @@ use Drupal\entity\Entity\EntityDescriptionInterface;
* }, * },
* ) * )
*/ */
class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescriptionInterface { class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescriptionInterface, RevisionableEntityBundleInterface {
/** /**
* The bundle ID. * The bundle ID.
...@@ -61,6 +62,13 @@ class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescr ...@@ -61,6 +62,13 @@ class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescr
*/ */
protected $description; protected $description;
/**
* Should new entities of this bundle have a new revision by default.
*
* @var bool
*/
protected $new_revision = FALSE;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -76,4 +84,11 @@ class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescr ...@@ -76,4 +84,11 @@ class EnhancedEntityBundle extends ConfigEntityBundleBase implements EntityDescr
return $this; return $this;
} }
/**
* {@inheritdoc}
*/
public function shouldCreateNewRevision() {
return $this->new_revision;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment