thunder_taxonomy.module in Thunder 8.2
Same filename and directory in other branches
- 8.5 modules/thunder_taxonomy/thunder_taxonomy.module
- 8.3 modules/thunder_taxonomy/thunder_taxonomy.module
- 8.4 modules/thunder_taxonomy/thunder_taxonomy.module
- 6.2.x 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\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_entity_base_field_info_alter().
*/
function thunder_taxonomy_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type
->id() == 'taxonomy_term') {
$fields['status']
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 120,
])
->setDisplayConfigurable('form', TRUE);
}
}
/**
* Implements hook_entity_type_alter().
*/
function thunder_taxonomy_entity_type_alter(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
if (!empty($entity_types['taxonomy_term'])) {
$entity_types['taxonomy_term']
->setAccessClass('Drupal\\thunder_taxonomy\\ThunderTermAccessControlHandler');
$entity_types['taxonomy_term']
->setFormClass('default', 'Drupal\\thunder_taxonomy\\ThunderTermForm');
}
}
/**
* 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_base_field_info_alter | Implements hook_entity_base_field_info_alter(). |
thunder_taxonomy_entity_type_alter | Implements hook_entity_type_alter(). |
thunder_taxonomy_form_taxonomy_overview_terms_alter | Implements hook_form_taxonomy_overview_terms_alter(). |