better_module_dependencies.module in Better Module Dependencies 8
Same filename and directory in other branches
Makes module dependencies clickable.
File
better_module_dependencies.moduleView source
<?php
/**
* @file
* Makes module dependencies clickable.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Template\Attribute;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_form_FORM_ID_alter().
*/
function better_module_dependencies_form_system_modules_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['#attached']['library'][] = 'better_module_dependencies/better_module_dependencies';
}
/**
* Implements hook_preprocess_HOOK().
*/
function better_module_dependencies_preprocess_item_list(&$variables) {
foreach ($variables['items'] as $key => &$item) {
if (isset($item['value']) && $item['value'] instanceof TranslatableMarkup) {
if (strpos($item['value']
->getUntranslatedString(), 'admin-missing')) {
if (isset($item['attributes']) && $item['attributes'] instanceof Attribute) {
$item['attributes']
->setAttribute('machine_name', $key);
}
}
}
}
}
Functions
Name![]() |
Description |
---|---|
better_module_dependencies_form_system_modules_alter | Implements hook_form_FORM_ID_alter(). |
better_module_dependencies_preprocess_item_list | Implements hook_preprocess_HOOK(). |