diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index f4b926e..db9cc70 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -333,7 +333,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { $executable = $this->getExecutable(); foreach ($executable->displayHandlers as $display_id => $display_handler) { - $display_handler->postSaveView($this->original->getDisplay($display_id)); + $display_handler->postSaveView(!empty($this->original) ? $this->original->getDisplay($display_id) : []); } // Rebuild the router case the view got enabled. diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 1f83a23..a034a7f 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -2604,7 +2604,7 @@ protected function isBaseTableTranslatable() { * Act on saving a view. * * @param array $orginal_display - * The display settings, of the original entity. + * The display settings, of the original entity empty in case of a new view. */ public function postSaveView(array $orginal_display) { } diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index e07a9a8..b7a12b5 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -494,7 +494,8 @@ public function calculateDependencies() { public function postSaveView(array $original_display) { parent::postSaveView($original_display); - $route_rebuild = FALSE; + // An empty original display means a new view, we need a router rebuild. + $route_rebuild = empty($original_display); $this->display['display_options'] += [ 'menu' => [], diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 3730d6b..fbba5b6 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -518,7 +518,8 @@ public function getAlteredRouteNames() { public function postSaveView(array $original_display) { parent::postSaveView($original_display); - $route_rebuild = FALSE; + // An empty original display means a new view, we need a router rebuild. + $route_rebuild = empty($original_display); $this->display['display_options'] += [ 'path' => '', diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 6350f0d..4837528 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -214,7 +214,7 @@ class ViewExecutable implements \Serializable { * An array containing Drupal\views\Plugin\views\display\DisplayPluginBase * objects. * - * @var \Drupal\views\DisplayPluginCollection + * @var \Drupal\views\DisplayPluginCollection|\Drupal\views\Plugin\views\display\DisplayPluginBase[] */ public $displayHandlers;