/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); $this->invalidateCaches(); // Rebuild the router if this is a new view, or it's status changed. if (!isset($this->original) || $this->status() != $this->original->status()) { \Drupal::service('router.builder')->setRebuildNeeded(); } }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); }
/** * {@inheritdoc} */ public static function preDelete(EntityStorageInterface $storage, array $entities) { parent::preDelete($storage, $entities); /** @var \Drupal\search_api\IndexInterface[] $entities */ foreach ($entities as $index) { if ($index->hasValidTracker()) { $index->getTracker()->trackAllItemsDeleted(); } if ($index->hasValidServer()) { $index->getServer()->removeIndex($index); } } if (\Drupal::moduleHandler()->moduleExists('views')) { views_invalidate_cache(); } }
/** * Tests invalid display plugins. */ public function testInvalidDisplayPlugins() { $this->drupalGet('test_display_invalid'); $this->assertResponse(200); // Change the page plugin id to an invalid one. Bypass the entity system // so no menu rebuild was executed (so the path is still available). $config = $this->config('views.view.test_display_invalid'); $config->set('display.page_1.display_plugin', 'invalid'); $config->save(); $this->drupalGet('test_display_invalid'); $this->assertResponse(200); $this->assertText('The "invalid" plugin does not exist.'); // Rebuild the router, and ensure that the path is not accessible anymore. views_invalidate_cache(); \Drupal::service('router.builder')->rebuildIfNeeded(); $this->drupalGet('test_display_invalid'); $this->assertResponse(404); // Change the display plugin ID back to the correct ID. $config = $this->config('views.view.test_display_invalid'); $config->set('display.page_1.display_plugin', 'page'); $config->save(); // Place the block display. $block = $this->drupalPlaceBlock('views_block:test_display_invalid-block_1', array(), array('title' => 'Invalid display')); $this->drupalGet('<front>'); $this->assertResponse(200); $this->assertBlockAppears($block); // Change the block plugin ID to an invalid one. $config = $this->config('views.view.test_display_invalid'); $config->set('display.block_1.display_plugin', 'invalid'); $config->save(); // Test the page is still displayed, the block not present, and has the // plugin warning message. $this->drupalGet('<front>'); $this->assertResponse(200); $this->assertText('The "invalid" plugin does not exist.'); $this->assertNoBlockAppears($block); }
/** * Submission handler to clear the Views cache. */ public function cacheSubmit() { views_invalidate_cache(); drupal_set_message($this->t('The cache has been cleared.')); }
<?php $viewname = 'taxonomy_term'; $status = variable_get('views_defaults', array()); // FALSE = Enable, TRUE = Disable. $status[$viewname] = FALSE; variable_set('views_defaults', $status); // Empty views cache. if (function_exists('views_invalidate_cache')) { views_invalidate_cache(); }
/** * {@inheritdoc} */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); // Rebuild the router case the view got enabled. if (!isset($this->original) || $this->status() != $this->original->status()) { \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } }