thunder_taxonomy.module in Thunder 6.2.x
Same filename and directory in other branches
- 8.5 modules/thunder_taxonomy/thunder_taxonomy.module
- 8.2 modules/thunder_taxonomy/thunder_taxonomy.module
- 8.3 modules/thunder_taxonomy/thunder_taxonomy.module
- 8.4 modules/thunder_taxonomy/thunder_taxonomy.module
- 6.0.x modules/thunder_taxonomy/thunder_taxonomy.module
- 6.1.x modules/thunder_taxonomy/thunder_taxonomy.module
Module for adding custom Infinity base functions.
File
modules/thunder_taxonomy/thunder_taxonomy.moduleView source
<?php
/**
* @file
* Module for adding custom Infinity base functions.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_entity_type_alter().
*/
function thunder_taxonomy_entity_type_alter(array &$entity_types) {
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
if (!empty($entity_types['taxonomy_term'])) {
$entity_types['taxonomy_term']
->setAccessClass('Drupal\\thunder_taxonomy\\ThunderTermAccessControlHandler');
}
}
/**
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\taxonomy\TermForm.
*/
function thunder_taxonomy_form_taxonomy_term_form_alter(&$form, FormStateInterface $form_state) {
// @todo Remove after seven / thunder_admin support is dropped.
$activeTheme = Drupal::theme()
->getActiveTheme()
->getName();
if (in_array($activeTheme, [
'seven',
'thunder_admin',
])) {
// Create sidebar group.
$form['advanced'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'entity-meta',
],
],
'#weight' => 99,
];
// Use the same form like node edit.
$form['#theme'] = [
'node_edit_form',
];
$form['#attached']['library'][] = 'seven/node-form';
// Move relations into sidebar.
$form['relations']['#group'] = 'advanced';
/** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
$form_object = $form_state
->getFormObject();
/** @var \Drupal\taxonomy\TermInterface $term */
$term = $form_object
->getEntity();
// Move pathauto into sidebar.
$form['path_settings'] = [
'#type' => 'details',
'#title' => t('URL path settings'),
'#open' => !empty($form['path']['widget'][0]['alias']['#value']),
'#group' => 'advanced',
'#access' => !empty($form['path']['#access']) && $term
->hasField('path') && $term
->get('path')
->access('edit'),
'#attributes' => [
'class' => [
'path-form',
],
],
'#attached' => [
'library' => [
'path/drupal.path',
],
],
'#weight' => 30,
];
$form['path']['#group'] = 'path_settings';
}
}
/**
* Implements hook_form_taxonomy_overview_terms_alter().
*/
function thunder_taxonomy_form_taxonomy_overview_terms_alter(&$form, FormStateInterface $formState) {
$form['terms']['#header'] = array_merge(array_slice($form['terms']['#header'], 0, 1, TRUE), [
t('Status'),
], array_slice($form['terms']['#header'], 1, NULL, TRUE));
foreach ($form['terms'] as &$term) {
if (is_array($term) && !empty($term['#term'])) {
$status['status'] = [
'#markup' => $term['#term']->status->value ? t('Published') : t('Unpublished'),
'#type' => 'item',
];
$term = array_slice($term, 0, 1, TRUE) + $status + array_slice($term, 1, NULL, TRUE);
}
}
}
Functions
Name | Description |
---|---|
thunder_taxonomy_entity_type_alter | Implements hook_entity_type_alter(). |
thunder_taxonomy_form_taxonomy_overview_terms_alter | Implements hook_form_taxonomy_overview_terms_alter(). |
thunder_taxonomy_form_taxonomy_term_form_alter | Implements hook_form_BASE_FORM_ID_alter() for \Drupal\taxonomy\TermForm. |