Skip to content
Snippets Groups Projects
Commit 48b0be39 authored by Joshua Sedler's avatar Joshua Sedler :cartwheel_tone2: Committed by Lee Rowlands
Browse files

Issue #3360374 by Anybody, Grevil, larowlan: Move the 'menu_link_content'...

Issue #3360374 by Anybody, Grevil, larowlan: Move the 'menu_link_content' 'link' base field widget overwrite into its own submodule
parent ac20b4fd
No related branches found
No related tags found
1 merge request!10Issue #3360374: Move the 'menu_link_content' 'link' base field widget overwrite into its own submodule
name: Link attributes
type: module
description: Provides a widget to allow settings of link attributes for menu links.
description: Provides a widget to allow settings of link attributes for link fields.
core_version_requirement: ^9 || ^10
dependencies:
- drupal:link
<?php
/**
* @file
* Install, update and uninstall functions for the Link attributes module.
*/
/**
* Update.
*
* Link Attribute's "menu_link_content" support is now a submodule.
* You may uninstall 'link_attributes_menu_link_content' if you do not use this
* functionality or have compatibility issue with other menu attribute modules.
*/
function link_attributes_update_9001() {
// Enable the link_attributes_menu_link_content submodule:
\Drupal::service('module_installer')->install(['link_attributes_menu_link_content']);
}
......@@ -5,21 +5,8 @@
* Contains main module functions.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_entity_base_field_info_alter().
*/
function link_attributes_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'menu_link_content') {
$fields['link']->setDisplayOptions('form', [
'type' => 'link_attributes',
'weight' => -2,
]);
}
}
/**
* Implements hook_help().
*/
......@@ -27,7 +14,7 @@ function link_attributes_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.link_attributes':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The link attributes module provides a widget that allows users to add attributes to links. It overtakes the core default widget for menu link content entities, allowing you to set attributes on menu links.') . '</p>';
$output .= '<p>' . t('The link attributes module provides a widget that allows users to add attributes to link fields. If you enable the Menu Link Content integration sub-module, it overtakes the core default widget for menu link content entities, allowing you to set attributes on menu links.') . '</p>';
return $output;
}
}
name: 'Link attributes: Menu Link Content integration'
type: module
description: Allows setting link attributes on menu links contents.
core_version_requirement: ^9 || ^10
dependencies:
- drupal:link
- drupal:link_attributes
<?php
/**
* @file
* Implements the link_attributes_menu_link_content functionality.
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_entity_base_field_info_alter().
*/
function link_attributes_menu_link_content_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'menu_link_content') {
$fields['link']->setDisplayOptions('form', [
'type' => 'link_attributes',
'weight' => -2,
]);
}
}
/**
* Implements hook_help().
*/
function link_attributes_menu_link_content_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.link_attributes_menu_link_content':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The "link_attributes_menu_link_content" sub-module provides a widget that allows users to add attributes to menu links. It overtakes the core default widget for menu link content entities, allowing you to set attributes on menu links.') . '</p>';
return $output;
}
}
<?php
namespace Drupal\Tests\link_attributes\Functional;
namespace Drupal\Tests\link_attributes_menu_link_content\Functional;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Tests\block\Traits\BlockCreationTrait;
......@@ -11,7 +11,7 @@ use Drupal\Tests\BrowserTestBase;
*
* @group link_attributes
*/
class LinkAttributesMenuTest extends BrowserTestBase {
class LinkAttributesMenuLinkContentMenuTest extends BrowserTestBase {
use BlockCreationTrait;
......@@ -20,6 +20,7 @@ class LinkAttributesMenuTest extends BrowserTestBase {
*/
protected static $modules = [
'link_attributes',
'link_attributes_menu_link_content',
'menu_ui',
'menu_link_content',
'block',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment