Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / media / tests / modules / media_test_source / src / Plugin / media / Source / TestWithConstraints.php
diff --git a/web/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithConstraints.php b/web/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithConstraints.php
new file mode 100644 (file)
index 0000000..98039ca
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\media_test_source\Plugin\media\Source;
+
+use Drupal\media\MediaSourceEntityConstraintsInterface;
+use Drupal\media\MediaSourceFieldConstraintsInterface;
+
+/**
+ * Provides generic media type.
+ *
+ * @MediaSource(
+ *   id = "test_constraints",
+ *   label = @Translation("Test source with constraints"),
+ *   description = @Translation("Test media source that provides constraints."),
+ *   allowed_field_types = {"string_long"},
+ * )
+ */
+class TestWithConstraints extends Test implements MediaSourceEntityConstraintsInterface, MediaSourceFieldConstraintsInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getEntityConstraints() {
+    return \Drupal::state()->get('media_source_test_entity_constraints', []);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getSourceFieldConstraints() {
+    return \Drupal::state()->get('media_source_test_field_constraints', []);
+  }
+
+}