Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_test_constraints / entity_test_constraints.module
diff --git a/web/core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module b/web/core/modules/system/tests/modules/entity_test_constraints/entity_test_constraints.module
new file mode 100644 (file)
index 0000000..684ffb3
--- /dev/null
@@ -0,0 +1,26 @@
+<?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);
+  }
+}