function menu_ui_entity_operation

Same name in other branches
  1. 10 core/modules/menu_ui/menu_ui.module \menu_ui_entity_operation()

Implements hook_entity_operation().

1 call to menu_ui_entity_operation()
MenuBlockTest::testOperationLinks in core/modules/menu_ui/tests/src/Kernel/MenuBlockTest.php
Tests the editing links for SystemMenuBlock.

File

core/modules/menu_ui/menu_ui.module, line 475

Code

function menu_ui_entity_operation(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;
}

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