diff --git a/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php b/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php index 06b1725..2d2d8ae 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsMenuLink.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; +use Drupal\views\Plugin\views\display\DisplayMenuInterface; use Drupal\views\Views; /** @@ -26,7 +27,9 @@ public function getDerivativeDefinitions($base_plugin_definition) { foreach ($views as $data) { /** @var \Drupal\views\ViewExecutable $view */ list($view, $display_id) = $data; - if ($result = $view->getMenuLinks($display_id)) { + $display = $view->displayHandlers->get($display_id); + + if (($display instanceof DisplayMenuInterface) && ($result = $display->getMenuLinks())) { foreach ($result as $link_id => $link) { $links[$link_id] = $link + $base_plugin_definition; } diff --git a/core/modules/views/src/Plugin/views/display/DisplayMenuInterface.php b/core/modules/views/src/Plugin/views/display/DisplayMenuInterface.php new file mode 100644 index 0000000..ec32559 --- /dev/null +++ b/core/modules/views/src/Plugin/views/display/DisplayMenuInterface.php @@ -0,0 +1,25 @@ +view->result) || $this->view->style_plugin->evenEmpty()) ? $this->view->style_plugin->render($this->view->result) : array(); @@ -2424,18 +2417,6 @@ public function newDisplay() { /** * {@inheritdoc} */ - public function remove() { - $menu_links = $this->getMenuLinks(); - /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ - $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); - foreach ($menu_links as $menu_link_id => $menu_link) { - $menu_link_manager->removeDefinition("views_view:$menu_link_id"); - } - } - - /** - * {@inheritdoc} - */ public function isIdentifierUnique($id, $identifier) { foreach (ViewExecutable::getHandlerTypes() as $type => $info) { foreach ($this->getHandlers($type) as $key => $handler) { diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php b/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php index b82de15..1e10462 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginInterface.php @@ -382,16 +382,6 @@ public function renderPager(); public function renderMoreLink(); /** - * Gets menu links, if this display provides some. - * - * @return array - * The menu links registers for this display. - * - * @see \Drupal\views\Plugin\Derivative\ViewsMenuLink - */ - public function getMenuLinks(); - - /** * Renders this display. */ public function render(); diff --git a/core/modules/views/src/Plugin/views/display/DisplayRouterInterface.php b/core/modules/views/src/Plugin/views/display/DisplayRouterInterface.php index 65328ed..03f651b 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayRouterInterface.php +++ b/core/modules/views/src/Plugin/views/display/DisplayRouterInterface.php @@ -71,4 +71,5 @@ public function getRouteName(); * @see \Drupal\views\Plugin\views\display\DisplayRouterInterface::alterRoutes() */ public function getAlteredRouteNames(); + } diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 415b704..7caf0dc 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -29,7 +29,7 @@ * * @see \Drupal\views\EventSubscriber\RouteSubscriber */ -abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouterInterface { +abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouterInterface, DisplayMenuInterface { use UrlGeneratorTrait; @@ -512,4 +512,16 @@ public function getAlteredRouteNames() { return $this->state->get('views.view_route_names') ?: array(); } + /** + * {@inheritdoc} + */ + public function remove() { + $menu_links = $this->getMenuLinks(); + /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ + $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); + foreach ($menu_links as $menu_link_id => $menu_link) { + $menu_link_manager->removeDefinition("views_view:$menu_link_id"); + } + } + } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index d5cd460..e697bba 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1629,29 +1629,6 @@ public function attachDisplays() { } /** - * Returns menu links from the view and the named display handler. - * - * @param string $display_id - * A display ID. - * - * @return array|bool - * The generated menu links for this view and display, FALSE if the call - * to ::setDisplay failed. - */ - public function getMenuLinks($display_id = NULL) { - // Prepare the view with the information we have. This was probably already - // called, but it's good to be safe. - if (!$this->setDisplay($display_id)) { - return FALSE; - } - - // Execute the hook. - if (isset($this->display_handler)) { - return $this->display_handler->getMenuLinks(); - } - } - - /** * Determine if the given user has access to the view. Note that * this sets the display handler if it hasn't been. */