Files
materio-d9/web/modules/custom/materio_admin/materio_admin.module
T
2026-09-23 21:14:58 +02:00

38 lines
1.3 KiB
PHP

<?php
/**
* @file
* Admin back-office enhancements.
*/
use Drupal\term_reference_tree\Plugin\Field\FieldWidget\TermReferenceTree;
/**
* Implements hook_field_widget_single_element_form_alter().
*
* Attaches the widget layout library wherever the term reference tree widget
* renders (thesaurus on materiau, etc.), so the selection tree (left) and the
* sortable track list (right) sit side by side.
*
* Transposed from the retired matminimal theme CSS, which was tied to the old
* adminimal-based admin theme. The selectors target the widget's own markup
* classes and are admin-theme agnostic (works under Gin 4 and Gin 5).
*/
function materio_admin_field_widget_single_element_form_alter(array &$element, \Drupal\Core\Form\FormStateInterface $form_state, array $context) {
if (isset($context['widget']) && $context['widget'] instanceof TermReferenceTree) {
$element['#attached']['library'][] = 'materio_admin/term_reference_tree';
}
}
/**
* Implements hook_page_attachments().
*
* Loads the general admin table styling on every admin route (compact
* paddings + constrained widths, replacing the old matminimal rules).
*/
function materio_admin_page_attachments(array &$attachments) {
if (\Drupal::service('router.admin_context')->isAdminRoute()) {
$attachments['#attached']['library'][] = 'materio_admin/admin_tables';
}
}