function Serializer::postSaveView

Same name and namespace in other branches
  1. 11.x core/modules/rest/src/Plugin/views/style/Serializer.php \Drupal\rest\Plugin\views\style\Serializer::postSaveView()

Acts on a saved view.

Parameters

\Drupal\views\PostSaveProcess $postSaveProcess: The views save context. Plugins flag work here instead of performing it directly, so it happens at most once per view save. For example, the block plugin queues the block plugin manager via ::addDiscoveryToClear() even if more than one block display changed.

\Drupal\views\Plugin\views\display\DisplayPluginInterface|null $original_display: (optional) The original display. Empty when saving a new view.

Overrides PostSaveViewInterface::postSaveView

File

core/modules/rest/src/Plugin/views/style/Serializer.php, line 152

Class

Serializer
The style plugin for serialized output formats.

Namespace

Drupal\rest\Plugin\views\style

Code

public function postSaveView(PostSaveProcess $postSaveProcess, ?DisplayPluginInterface $original_display = NULL) : void {
  if ($postSaveProcess->needsRouterRebuild()) {
    return;
  }
  // We need a router rebuild if the available formats have changed because
  // the formats are stored on the route.
  $original_style = $original_display?->getOption('style') ?? [];
  $original_formats = $original_style['options']['formats'] ?? [];
  if ($original_formats != $this->getFormats()) {
    $postSaveProcess->setRouterRebuild();
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.