diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 93e286f..1bb9b07 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -10,6 +10,7 @@ use Drupal\Core\Routing\RouteCompiler; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\State\StateInterface; +use Drupal\views\Plugin\views\display\PathPluginTrait; use Drupal\views\Plugin\views\display\ResponseDisplayPluginInterface; use Drupal\views\Render\ViewsRenderPipelineMarkup; use Drupal\views\ViewExecutable; @@ -34,6 +35,8 @@ */ class RestExport extends PathPluginBase implements ResponseDisplayPluginInterface { + use PathPluginTrait; + /** * {@inheritdoc} */ diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 3654d63..2ff8d9b 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -239,9 +239,15 @@ public function collectRoutes(RouteCollection $collection) { * @return bool * TRUE, when the view should override the given route. */ - protected function overrideApplies($view_path, Route $view_route, Route $route) { - return $this->overrideAppliesPathAndMethod($view_path, $view_route, $route) - && (!$route->hasRequirement('_format') || $route->getRequirement('_format') === 'html'); + protected function _overrideApplies($view_path, Route $view_route, Route $route) { + // Forward port of the 8.3.x API. + if ($this instanceof PathPluginTrait) { + return $this->overrideApplies($view_path, $view_route, $route); + } + else { + return $this->overrideAppliesPathAndMethod($view_path, $view_route, $route) + && (!$route->hasRequirement('_format') || $route->getRequirement('_format') === 'html'); + } } /** @@ -281,7 +287,7 @@ public function alterRoutes(RouteCollection $collection) { $view_route = $this->getRoute($view_id, $display_id); foreach ($collection->all() as $name => $route) { - if ($this->overrideApplies($view_path, $view_route, $route)) { + if ($this->_overrideApplies($view_path, $view_route, $route)) { $parameters = $route->compile()->getPathVariables(); // @todo Figure out whether we need to merge some settings (like diff --git a/core/modules/views/src/Plugin/views/display/PathPluginTrait.php b/core/modules/views/src/Plugin/views/display/PathPluginTrait.php new file mode 100644 index 0000000..5a7ebe2 --- /dev/null +++ b/core/modules/views/src/Plugin/views/display/PathPluginTrait.php @@ -0,0 +1,29 @@ +