function View::postSave
Same name and namespace in other branches
- 11.x core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::postSave()
- 10 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::postSave()
- 9 core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::postSave()
- 8.9.x core/modules/views/src/Entity/View.php \Drupal\views\Entity\View::postSave()
Overrides EntityBase::postSave
File
-
core/
modules/ views/ src/ Entity/ View.php, line 350
Class
- View
- Defines a View configuration entity class.
Namespace
Drupal\views\EntityCode
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
Views::invalidateCache();
// Track for each display, handler and plugin whether action was taken in
// the postsave callback.
$postSaveProcess = new PostSaveProcess();
$executable = $this->getExecutable();
$original_executable = NULL;
if ($this->getOriginal()) {
$original_executable = $this->getOriginal()
->getExecutable();
$original_executable->initDisplay();
}
$executable->initDisplay();
foreach ($executable->displayHandlers as $display_id => $display_handler) {
$original_display_handler = NULL;
if ($original_executable && $original_executable->displayHandlers
->has($display_id)) {
$original_executable->setDisplay($display_id);
$original_display_handler = $original_executable->display_handler;
}
if ($display_handler instanceof PostSaveViewInterface) {
$display_handler->postSaveView($postSaveProcess, $original_display_handler);
}
foreach (\array_keys(Views::getHandlerTypes()) as $handler_type) {
foreach ($display_handler->getHandlers($handler_type) as $handler) {
if ($handler instanceof PostSaveViewInterface) {
$handler->postSaveView($postSaveProcess, $original_display_handler);
}
}
}
foreach (Views::getPluginTypes('plugin') as $plugin_type) {
$plugin = $display_handler->getPlugin($plugin_type);
if (!empty($plugin) && $plugin instanceof PostSaveViewInterface) {
$plugin->postSaveView($postSaveProcess, $original_display_handler);
}
}
}
if ($postSaveProcess->needsRouterRebuild()) {
// Set the router as needing to be rebuilt.
\Drupal::service('router.builder')->setRebuildNeeded();
// Reset the RouteSubscriber from views.
\Drupal::service('views.route_subscriber')->reset();
}
foreach ($postSaveProcess->getDiscoveriesToClear() as $discovery) {
$discovery->clearCachedDefinitions();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.