link_attributes.module in Link Attributes widget 8
Contains main module functions.
File
link_attributes.moduleView source
<?php
/**
* @file
* 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().
*/
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>';
return $output;
}
}
Functions
Name | Description |
---|---|
link_attributes_entity_base_field_info_alter | Implements hook_entity_base_field_info_alter(). |
link_attributes_help | Implements hook_help(). |