You are here

thunder_taxonomy.module in Thunder 6.1.x

Module for adding custom Infinity base functions.

File

modules/thunder_taxonomy/thunder_taxonomy.module
View 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');
    $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

Namesort descending 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().