Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ViewsMenuLink.php

function ViewsMenuLink::updateLink

Overrides MenuLinkInterface::updateLink

File

core/modules/views/src/Plugin/Menu/ViewsMenuLink.php, line 132

Class

ViewsMenuLink
Defines menu links provided by views.

Namespace

Drupal\views\Plugin\Menu

Code

public function updateLink(array $new_definition_values, $persist) {
    $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
    // Update the definition.
    $this->pluginDefinition = $overrides + $this->pluginDefinition;
    if ($persist) {
        $view = $this->loadView();
        $display =& $view->storage
            ->getDisplay($view->current_display);
        // Just save the title to the original view.
        $changed = FALSE;
        foreach ($overrides as $key => $new_definition_value) {
            if (empty($display['display_options']['menu'][$key]) || $display['display_options']['menu'][$key] != $new_definition_value) {
                $display['display_options']['menu'][$key] = $new_definition_value;
                $changed = TRUE;
            }
        }
        if ($changed) {
            // @todo Improve this to not trigger a full rebuild of everything, if we
            //   just changed some properties. https://www.drupal.org/node/2310389
            $view->storage
                ->save();
        }
    }
    return $this->pluginDefinition;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal