Skip to content
Snippets Groups Projects
Commit b6b7891e authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2596345 by mbovan, Nitesh Pawar, Shreya Shetty, dawehner: Deleting a...

Issue #2596345 by mbovan, Nitesh Pawar, Shreya Shetty, dawehner: Deleting a view should rebuild the routes
parent 4706f543
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Routing\RouteMatchInterface;
......@@ -804,3 +805,18 @@ function views_local_tasks_alter(&$local_tasks) {
$local_task = ViewsLocalTask::create($container, 'views_view');
$local_task->alterLocalTasks($local_tasks);
}
/**
* Implements hook_ENTITY_TYPE_delete().
*/
function views_view_delete(EntityInterface $entity) {
// Rebuild the routes in case there is a routed display.
$executable = Views::executableFactory()->get($entity);
$executable->initDisplay();
foreach ($executable->displayHandlers as $display) {
if ($display->getRoutedDisplay()) {
\Drupal::service('router.builder')->setRebuildNeeded();
break;
}
}
}
......@@ -142,6 +142,23 @@ function testDefaultViews() {
$this->drupalGet($edit_href);
$this->assertResponse(404);
$this->assertText('Page not found');
// Delete all duplicated Glossary views.
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
// Submit the confirmation form.
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(200);
$this->drupalGet('admin/structure/views');
$this->clickViewsOperationLink(t('Delete'), $random_name);
// Submit the confirmation form.
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->drupalGet('glossary');
$this->assertResponse(404);
$this->assertText('Page not found');
}
/**
......
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