function MenuLinkBase::getOperations

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Menu/MenuLinkBase.php \Drupal\Core\Menu\MenuLinkBase::getOperations()

Provides an array of information to build a list of operation links.

Return value

array An associative array of operation link data for this menu link, keyed by operation name, containing the following key-value pairs:

  • title: The localized title of the operation.
  • url: An instance of \Drupal\Core\Url for the operation URL.
  • weight: The weight of this operation.

Overrides MenuLinkInterface::getOperations

1 method overrides MenuLinkBase::getOperations()
MenuLinkContent::getOperations in core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php
Provides an array of information to build a list of operation links.

File

core/lib/Drupal/Core/Menu/MenuLinkBase.php, line 173

Class

MenuLinkBase
Defines a base menu link class.

Namespace

Drupal\Core\Menu

Code

public function getOperations() : array {
  $operations = [];
  $operations['edit'] = [
    'title' => $this->t('Edit'),
    'url' => $this->getEditRoute(),
  ];
  // Links can either be reset or deleted, not both.
  if ($this->isResettable()) {
    $operations['reset'] = [
      'title' => $this->t('Reset'),
      'url' => $this->getResetRoute(),
    ];
  }
  elseif ($this->isDeletable()) {
    $operations['delete'] = [
      'title' => $this->t('Delete'),
      'url' => $this->getDeleteRoute(),
    ];
  }
  if ($this->isTranslatable()) {
    $operations['translate'] = [
      'title' => $this->t('Translate'),
      'url' => $this->getTranslateRoute(),
    ];
  }
  return $operations;
}

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