Results
27.01.2025
taxonomy_menu_sync 1.0.4 ::
taxonomy_menu_sync.module
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\menu_link_content\Form\MenuLinkContentForm; use Drupal\menu_link_content\Plugin\Menu\MenuLinkContent; use Drupal\menu_ui\MenuForm; /** * Implements hook_help(). */
if (str_contains($form_id, 'menu_link_content_')) {
/** @var \Drupal\menu_link_content\Form\MenuLinkContentForm $form_object */
$form_object = $form_state->getFormObject();
if (!$form_object instanceof MenuLinkContentForm || taxonomy_menu_sync_user_restrict()) {
return;
}
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_entity */
$menu_entity = $form_object->getEntity();
$menu_content_id = $menu_entity->id(); 02.09.2025
autocomplete_extras 1.0.0 ::
src/Hook/AutocompleteExtrasHooks.php
*/
#[Hook('form_menu_link_content_menu_link_content_form_alter')]
public function formMenuLinkContentMenuLinkContentFormAlter(&$form, $form_state): void {
$config = $this->configFactory->get('autocomplete_extras.settings');
if ($config->get('menu_link_content.enabled') ?? FALSE) {
$match_limit = $config->get('menu_link_content.match_limit') ?? self::DEFAULT_MATCH_LIMIT;
$min_length = $config->get('menu_link_content.min_length') ?? self::DEFAULT_MIN_LENGTH; 02.09.2025
autocomplete_extras 1.0.0 ::
autocomplete_extras.module
#[LegacyHook]
function autocomplete_extras_form_menu_link_content_menu_link_content_form_alter(&$form, FormStateInterface $form_state): void {
\Drupal::service(AutocompleteExtrasHooks::class)->formMenuLinkContentMenuLinkContentFormAlter($form, $form_state);
} 01.09.2025
entity_attributes 1.1.0 ::
src/Plugin/Field/FieldWidget/AttributesWidget.php
// The field structure on the Menu Link Content form is different,
// and the details wrapper is added by alterMenuLinkContentForm().
elseif ($form_state->getFormObject()->getFormId() == 'menu_link_content_menu_link_content_form') {
$element += [
'#type' => 'container',
];
}
// Otherwise, render as a regular details element. 01.09.2025
entity_attributes 1.1.0 ::
src/Hook/FieldHooks.php
*/
#[Hook('form_menu_link_content_form_alter')]
public function formMenuLinkContentFormAlter(array &$form, FormStateInterface $form_state, string $form_id): void {
// Adjust the entity_attributes field for menu link content.
$this->fieldHandler->alterMenuLinkContentForm($form, $form_state, $form_id);
}
/**
* Implements hook_form_FORM_ID_alter() for menu_link_edit.
*
* @usedby StaticMenuLinkAttributes 01.09.2025
entity_attributes 1.1.0 ::
src/EntityAttributesField.php
* The form ID.
*/
public function alterMenuLinkContentForm(array &$form, FormStateInterface $form_state, string $form_id): void {
if (!$this->pluginManager->isPluginEnabled('menu_link_content', 'menu_link_content')) {
return;
}
// Checking the entity_attributes field exists in the form.
if (!isset($form['entity_attributes'])) { 27.06.2020
domain_entity 8.x-1.0-beta1 ::
modules/domain_menu_access/domain_menu_access.module
/**
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\menu_link_content\MenuLinkContentForm.
*
* Move Domain Access fields to an advanced tab like other node settings.
*/
function domain_menu_access_form_menu_link_content_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/** @var \Drupal\menu_link_content\Form\MenuLinkContentForm $form_object */
$form_object = $form_state->getFormObject();
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */
$entity = $form_object->getEntity();
/** @var \Drupal\system\MenuInterface $menu */
$form['domain'] = [ 11.04.2019
domain_menu_access 8.x-1.x-dev ::
domain_menu_access.module
*/
function domain_menu_access_form_menu_link_content_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/** @var \Drupal\menu_link_content\Form\MenuLinkContentForm $form_object */
$form_object = $form_state->getFormObject();
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */
$entity = $form_object->getEntity();
$config = \Drupal::config('domain_menu_access.settings')->get('menu_enabled'); 23.09.2020
entity_hierarchy 8.x-2.24 ::
modules/entity_hierarchy_microsite/src/Form/MicrositeMenuItemForm.php
/** * Constructs a MenuLinkContentForm object. * * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository * The entity repository. * @param \Drupal\Core\Menu\MenuParentFormSelectorInterface $menu_parent_selector * The menu parent form selector service. * @param \Drupal\Core\Path\PathValidatorInterface $path_validator
23.09.2020
entity_hierarchy 8.x-2.24 ::
modules/entity_hierarchy_microsite/entity_hierarchy_microsite.links.menu.yml
entity_hierarchy_microsite: class: \Drupal\entity_hierarchy_microsite\Plugin\Menu\MicrositeMenuItem form_class: \Drupal\entity_hierarchy_microsite\Form\MenuLinkContentForm deriver: \Drupal\entity_hierarchy_microsite\Plugin\Deriver\MicrositeMenuItemDeriver
12.10.2020
group_content_menu 8.x-1.0-rc3 ::
src/Form/MenuLinkItemForm.php
use Drupal\Core\Form\FormStateInterface;
use Drupal\menu_link_content\Form\MenuLinkContentForm;
/**
* Form wrapper for MenuLinkContentForm.
*
* @ingroup group_content_menu
*/
final class MenuLinkItemForm extends MenuLinkContentForm {
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state); 05.04.2019
groupmenu 8.x-1.0-beta2 ::
groupmenu.module
use Drupal\group\Entity\GroupRelationship; use Drupal\group\Entity\GroupRelationshipType; use Drupal\menu_link_content\Form\MenuLinkContentForm; use Drupal\menu_ui\Form\MenuLinkEditForm; use Drupal\system\MenuInterface; /** * Implements hook_entity_create_access(). *
// Filter menu options to group menus.
if ($form_object instanceof MenuLinkEditForm || $form_object instanceof MenuLinkContentForm) {
$account = \Drupal::currentUser();
if (!$account->hasPermission('administer menu')) {
groupmenu_filter_parent_options($form['menu_parent']['#options']);
}
} 15.10.2020
improvements 2.x-dev ::
modules/improvements_menu/src/ImprovementsMenuTrustedCallbacks.php
public static function trustedCallbacks(): array {
return [
'menuLinkContentFormPreRender',
];
}
/**
* Pre render callback for menu_link_content_form form.
*
* @see improvements_form_menu_link_content_form_alter()
*/
public static function menuLinkContentFormPreRender(array $form): array {
$form['description']['#weight'] = -1.1;
return $form;
}
} 15.10.2020
improvements 2.x-dev ::
modules/improvements_menu/improvements_menu.module
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Menu\MenuLinkInterface; use Drupal\menu_link_content\Form\MenuLinkContentForm; use Drupal\menu_link_content\MenuLinkContentInterface; use Drupal\menu_ui\Form\MenuLinkEditForm; use Drupal\system\Entity\Menu; use Drupal\system\Plugin\Block\SystemMenuBlock; require_once __DIR__ . '/improvements_menu.link_advanced_settings.inc';
* Implements hook_form_FORM_ID_alter(): menu_link_content_form.
*
* @see \Drupal\menu_link_content\Form\MenuLinkContentForm::form()
*/
function improvements_menu_form_menu_link_content_form_alter(array &$form, FormStateInterface $form_state): void {
$menu_link_form_object = $form_state->getFormObject(); /** @var MenuLinkContentForm $menu_link_form_object */
$menu_link = $menu_link_form_object->getEntity(); /** @var MenuLinkContentInterface $menu_link */
// Add autofocus to menu link title
if (isset($form['title']['widget'][0]['value'])) {
$form['title']['widget'][0]['value']['#attributes']['autofocus'] = 'autofocus';
}
$form['#entity_builders'][] = 'improvements_menu_link_content_entity_builder'; $form['actions']['submit']['#submit'][] = 'improvements_menu_link_form_submit'; $form['#pre_render'][] = '\Drupal\improvements_menu\ImprovementsMenuTrustedCallbacks::menuLinkContentFormPreRender'; improvements_menu_link_advanced_settings_form_alter($form, $form_state); } /** * Implements hook_form_FORM_ID_alter(): menu_link_edit.
15.10.2020
improvements 2.x-dev ::
modules/improvements_menu/improvements_menu.link_advanced_settings.inc
use Drupal\Core\Url; use Drupal\druhels\DrupalHelper; use Drupal\menu_link_content\Form\MenuLinkContentForm; use Drupal\menu_link_content\MenuLinkContentInterface; use Drupal\menu_ui\Form\MenuLinkEditForm; use Drupal\menu_ui\MenuForm; use Drupal\system\Entity\Menu; use Drupal\system\MenuInterface;
$form_object = $form_state->getFormObject();
if ($form_object instanceof MenuLinkContentForm) {
$menu_link = $form_object->getEntity(); /** @var MenuLinkContentInterface $menu_link */
}
elseif ($form_object instanceof MenuLinkEditForm) {
$menu_link = $form_state->getBuildInfo()['args'][0]; /** @var MenuLinkInterface $menu_link */
}
else { 09.06.2023
menu_bootstrap_icon 1.x-dev ::
src/Hook/BootstrapIconHook.php
* #[Hook('form_menu_link_content_form_alter')]
*/
public function formMenuLinkContentFormAlter(&$form, FormStateInterface $form_state, $form_id) : void {
$menu_link = $form_state->getFormObject()->getEntity();
$options = $menu_link->link->first()->options ?: [];
$this->menuBootstrapIconForm($form, $options);
$this->menuBootstrapIconRole($form, $options);
$form['actions']['submit']['#submit'][] = [static::class, 'menuLinkContentFormSubmit'];
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* #[Hook('form_menu_link_edit_alter')]
* @throws \Drupal\Core\Entity\EntityStorageException
*/
protected function menuLinkContentFormSubmit(array $form, FormStateInterface $form_state) {
$icon_field = $form_state->getValue('icon');
$icon_tag = $form_state->getValue('icon_tag');
$icon_appearance = $form_state->getValue('icon_appearance');
$roles = array_filter($form_state->getValue('menu_item_roles') ?? []);
$options = [ 20.04.2022
menu_disallow_external_links 1.0.0-rc1 ::
menu_disallow_external_links.module
function menu_disallow_external_links_form_menu_link_content_menu_link_content_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Get menu link object.
/** @var Drupal\menu_link_content\Form\MenuLinkContentForm */
$form_object = $form_state->getFormObject();
/** @var Drupal\menu_link_content\Entity\MenuLinkContent */
$menu_link = $form_object->getEntity();
// Determine whether the link belongs to a menu that disallows external links.
$menu_name = $menu_link->getMenuName(); 12.03.2018
menu_link_highlight 8.x-1.x-dev ::
menu_link_highlight.module
*/
function menu_link_highlight_menu_link_content_form_submit($form, FormStateInterface $form_state) {
/** @var \Drupal\menu_link_content\Form\MenuLinkContentForm $form_object */
$form_object = $form_state->getFormObject();
$menu_link = $form_object->getEntity();
if (!$menu_link->link) {
return;
} 17.05.2022
menu_lock 1.0.0-rc1 ::
menu_lock.module
// Retrieve current user account + menu link object.
$account = \Drupal::currentUser()->getAccount();
/** @var Drupal\menu_link_content\Form\MenuLinkContentForm */
$form_object = $form_state->getFormObject();
/** @var Drupal\menu_link_content\Entity\MenuLinkContent */
$menu_link = $form_object->getEntity();
// Limit options in 'Parent link' field.
if (!empty($form['menu_parent']['#options']) && !$account->hasPermission('move menu links across menus')) { 28.03.2020
menu_per_role 8.x-1.x-dev ::
menu_per_role.module
$is_content = FALSE;
if ($hide_on_content_mode != MenuPerRoleAdminSettings::MODE_DISPLAY_ON_CONTENT_ALWAYS) {
/** @var \Drupal\menu_link_content\Form\MenuLinkContentForm $form_obj */
$form_obj = $form_state->getFormObject();
/** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link */
$menu_link = $form_obj->getEntity();
if (!$menu_link->isNew()) {
$link_url = $menu_link->getUrlObject();
if ($link_url->isRouted()) { 