menu_link_content.module

Same filename in other branches
  1. 9 core/modules/menu_link_content/menu_link_content.module
  2. 8.9.x core/modules/menu_link_content/menu_link_content.module
  3. 10 core/modules/menu_link_content/menu_link_content.module

File

core/modules/menu_link_content/menu_link_content.module

View source
<?php


/**
 * @file
 */

/**
 * Helper function to update plugin definition using internal scheme.
 *
 * @param string $path
 *   The path alias.
 */
function _menu_link_content_update_path_alias($path) {
    
    /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    
    /** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $entities */
    $entities = \Drupal::entityTypeManager()->getStorage('menu_link_content')
        ->loadByProperties([
        'link.uri' => 'internal:' . $path,
    ]);
    foreach ($entities as $menu_link) {
        $menu_link_manager->updateDefinition($menu_link->getPluginId(), $menu_link->getPluginDefinition(), FALSE);
    }
}

Functions

Title Deprecated Summary
_menu_link_content_update_path_alias Helper function to update plugin definition using internal scheme.

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