Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / media / tests / modules / media_test_source / src / Plugin / media / Source / TestTranslation.php
1 <?php
2
3 namespace Drupal\media_test_source\Plugin\media\Source;
4
5 use Drupal\media\MediaInterface;
6
7 /**
8  * Provides test media source.
9  *
10  * @MediaSource(
11  *   id = "test_translation",
12  *   label = @Translation("Test source with translations"),
13  *   description = @Translation("Test media source with translations."),
14  *   allowed_field_types = {"string"},
15  *   thumbnail_alt_metadata_attribute = "test_thumbnail_alt",
16  * )
17  */
18 class TestTranslation extends Test {
19
20   /**
21    * {@inheritdoc}
22    */
23   public function getMetadata(MediaInterface $media, $attribute_name) {
24     if ($attribute_name == 'thumbnail_uri') {
25       return 'public://' . $media->language()->getId() . '.png';
26     }
27
28     if ($attribute_name == 'test_thumbnail_alt') {
29       $langcode = $media->language()->getId();
30       return $this->t('Test Thumbnail @language', ['@language' => $langcode], ['langcode' => $langcode]);
31     }
32
33     return parent::getMetadata($media, $attribute_name);
34   }
35
36 }