You are here

taxonomy_test.module in Drupal 8

Provides test hook implementations for taxonomy tests.

File

core/modules/taxonomy/tests/modules/taxonomy_test/taxonomy_test.module
View source
<?php

/**
 * @file
 * Provides test hook implementations for taxonomy tests.
 */
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_query_alter().
 */
function taxonomy_test_query_alter(AlterableInterface $query) {
  $value = \Drupal::state()
    ->get(__FUNCTION__);
  if (isset($value)) {
    \Drupal::state()
      ->set(__FUNCTION__, ++$value);
  }
}

/**
 * Implements hook_query_TAG_alter().
 */
function taxonomy_test_query_term_access_alter(AlterableInterface $query) {
  $value = \Drupal::state()
    ->get(__FUNCTION__);
  if (isset($value)) {
    \Drupal::state()
      ->set(__FUNCTION__, ++$value);
  }
}

/**
 * Implements hook_query_TAG_alter().
 */
function taxonomy_test_query_taxonomy_term_access_alter(AlterableInterface $query) {
  $value = \Drupal::state()
    ->get(__FUNCTION__);
  if (isset($value)) {
    \Drupal::state()
      ->set(__FUNCTION__, ++$value);
  }
}

/**
 * Implements hook_form_BASE_FORM_ID_alter() for the taxonomy term form.
 */
function taxonomy_test_form_taxonomy_term_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if (\Drupal::state()
    ->get('taxonomy_test.disable_parent_form_element', FALSE)) {
    $form['relations']['parent']['#disabled'] = TRUE;
  }
}