EntityTestConstraintsHooks.php

Namespace

Drupal\entity_test_constraints\Hook

File

core/modules/system/tests/modules/entity_test_constraints/src/Hook/EntityTestConstraintsHooks.php

View source
<?php

declare (strict_types=1);
namespace Drupal\entity_test_constraints\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for entity_test_constraints.
 */
class EntityTestConstraintsHooks {
  
  /**
   * Implements hook_entity_type_build().
   */
  public function entityTypeBuild(array &$entity_types) : void {
    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().
   */
  public function entityTypeAlter(array &$entity_types) : void {
    if ($alter = \Drupal::state()->get('entity_test_constraints.alter')) {
      $entity_types['entity_test_constraints']->setConstraints($alter);
    }
  }

}

Classes

Title Deprecated Summary
EntityTestConstraintsHooks Hook implementations for entity_test_constraints.

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