summaryrefslogtreecommitdiffstats
path: root/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php')
-rw-r--r--core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php b/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php
new file mode 100644
index 0000000..947f067
--- /dev/null
+++ b/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\media_test_source\Plugin\media\Source;
+
+use Drupal\media\MediaInterface;
+
+/**
+ * Provides test media source.
+ *
+ * @MediaSource(
+ * id = "test_translation",
+ * label = @Translation("Test source with translations"),
+ * description = @Translation("Test media source with translations."),
+ * allowed_field_types = {"string"},
+ * thumbnail_alt_metadata_attribute = "test_thumbnail_alt",
+ * )
+ */
+class TestTranslation extends Test {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMetadata(MediaInterface $media, $attribute_name) {
+ if ($attribute_name == 'thumbnail_uri') {
+ return 'public://' . $media->language()->getId() . '.png';
+ }
+
+ if ($attribute_name == 'test_thumbnail_alt') {
+ $langcode = $media->language()->getId();
+ return $this->t('Test Thumbnail @language', ['@language' => $langcode], ['langcode' => $langcode]);
+ }
+
+ return parent::getMetadata($media, $attribute_name);
+ }
+
+}