diff --git a/modules/core/quick/src/Entity/QuickFormInstance.php b/modules/core/quick/src/Entity/QuickFormInstance.php index 5a2c106f7..c289f2719 100644 --- a/modules/core/quick/src/Entity/QuickFormInstance.php +++ b/modules/core/quick/src/Entity/QuickFormInstance.php @@ -175,4 +175,20 @@ class QuickFormInstance extends ConfigEntityBase implements QuickFormInstanceInt } } + /** + * {@inheritdoc} + */ + public function postSave(EntityStorageInterface $storage, $update = TRUE) { + parent::postSave($storage, $update); + \Drupal::service('router.builder')->setRebuildNeeded(); + } + + /** + * {@inheritdoc} + */ + public static function postDelete(EntityStorageInterface $storage, array $entities) { + parent::postDelete($storage, $entities); + \Drupal::service('router.builder')->setRebuildNeeded(); + } + } diff --git a/modules/core/quick/tests/src/Functional/QuickFormTest.php b/modules/core/quick/tests/src/Functional/QuickFormTest.php index 12b1182c3..3077308d5 100644 --- a/modules/core/quick/tests/src/Functional/QuickFormTest.php +++ b/modules/core/quick/tests/src/Functional/QuickFormTest.php @@ -146,6 +146,9 @@ class QuickFormTest extends FarmBrowserTestBase { ]); $config_entity->save(); + // Rebuild routes. + \Drupal::service('router.builder')->rebuildIfNeeded(); + // Go to the quick form index and confirm that the requires_entity_test // quick form item is visible. $this->drupalGet('quick'); @@ -157,6 +160,15 @@ class QuickFormTest extends FarmBrowserTestBase { $this->drupalGet('quick/requires_entity_test'); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains($this->t('Test field')); + + // Delete the config entity and confirm that it is removed. + $config_entity->delete(); + \Drupal::service('router.builder')->rebuildIfNeeded(); + $this->drupalGet('quick'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextNotContains($this->t('Test requiresEntity quick form')); + $this->drupalGet('quick/requires_entity_test'); + $this->assertSession()->statusCodeEquals(404); } }