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

Breadcrumb

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

function MenuUiHooks::entityOperation

Implements hook_entity_operation().

File

core/modules/menu_ui/src/Hook/MenuUiHooks.php, line 282

Class

MenuUiHooks
Hook implementations for menu_ui.

Namespace

Drupal\menu_ui\Hook

Code

public function entityOperation(EntityInterface $entity) : array {
    $operations = [];
    if ($entity instanceof BlockInterface) {
        $plugin = $entity->getPlugin();
        if ($plugin->getBaseId() === 'system_menu_block') {
            $menu = Menu::load($plugin->getDerivativeId());
            if ($menu && $menu->access('edit')) {
                $operations['menu-edit'] = [
                    'title' => t('Edit menu'),
                    'url' => $menu->toUrl('edit-form'),
                    'weight' => 50,
                ];
            }
        }
    }
    return $operations;
}

API Navigation

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