entity_test_constraints.module

Same filename in other branches
  1. 9 core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module
  2. 8.9.x core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module
  3. 11.x core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module

Test module file.

File

core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module

View source
<?php


/**
 * @file
 * Test module file.
 */

/**
 * Implements hook_entity_type_build().
 */
function entity_test_constraints_entity_type_build(array &$entity_types) {
    if ($extra = \Drupal::state()->get('entity_test_constraints.build')) {
        foreach ($extra as $id => $option) {
            $entity_types['entity_test_constraints']->addConstraint($id, $option);
        }
    }
}

/**
 * Implements hook_entity_type_alter().
 */
function entity_test_constraints_entity_type_alter(array &$entity_types) {
    if ($alter = \Drupal::state()->get('entity_test_constraints.alter')) {
        $entity_types['entity_test_constraints']->setConstraints($alter);
    }
}

Functions

Title Deprecated Summary
entity_test_constraints_entity_type_alter Implements hook_entity_type_alter().
entity_test_constraints_entity_type_build Implements hook_entity_type_build().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.