TestTranslation.php

Same filename in other branches
  1. 9 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php
  2. 8.9.x core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php
  3. 10 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php

Namespace

Drupal\media_test_source\Plugin\media\Source

File

core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestTranslation.php

View source
<?php

declare (strict_types=1);
namespace Drupal\media_test_source\Plugin\media\Source;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\media\Attribute\MediaSource;
use Drupal\media\MediaInterface;

/**
 * Provides test media source.
 */
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);
    }

}

Classes

Title Deprecated Summary
TestTranslation Provides test media source.

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