menu_operations_link_test.module

Same filename in other branches
  1. 10 core/modules/menu_link_content/tests/menu_operations_link_test/menu_operations_link_test.module

File

core/modules/menu_link_content/tests/menu_operations_link_test/menu_operations_link_test.module

View source
<?php


/**
 * @file
 * Primary module hooks for Menu Operations Link Test module.
 */
declare (strict_types=1);
use Drupal\Core\Entity\EntityInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Core\Url;

/**
 * Implements hook_entity_operation_alter().
 */
function menu_operations_link_test_entity_operation_alter(array &$operations, EntityInterface $entity) {
    if (!$entity instanceof MenuLinkContent) {
        return;
    }
    // Alter the title of the edit link appearing in operations menu.
    $operations['edit']['title'] = t('Altered Edit Title');
}

/**
 * Implements hook_entity_operation().
 */
function menu_operations_link_test_entity_operation(EntityInterface $entity) {
    if (!$entity instanceof MenuLinkContent) {
        return;
    }
    $operations['custom_operation'] = [
        'title' => t('Custom Home'),
        'weight' => 20,
        'url' => Url::fromRoute('<front>'),
    ];
    return $operations;
}

Functions

Title Deprecated Summary
menu_operations_link_test_entity_operation Implements hook_entity_operation().
menu_operations_link_test_entity_operation_alter Implements hook_entity_operation_alter().

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