diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index d2f66fff95..dd5ae28afd 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -328,6 +328,10 @@ public function collectRoutes(RouteCollection $collection) { if ($route = $collection->get("view.$view_id.$display_id")) { $style_plugin = $this->getPlugin('style'); + if (!method_exists($style_plugin, 'getFormats') || !method_exists($style_plugin, 'getFormatOptions')) { + $class_name = get_class($style_plugin); + throw new \Exception("Views style plugins used with REST exports must provide methods getFormats and getFormatOptions. Plugin class {$class_name} doesn't provide these methods."); + } // REST exports should only respond to GET methods. $route->setMethods(['GET']);