function TestDifferentDisplays::prepareViewDisplay

Same name in other branches
  1. 9 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php \Drupal\media_test_source\Plugin\media\Source\TestDifferentDisplays::prepareViewDisplay()
  2. 8.9.x core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php \Drupal\media_test_source\Plugin\media\Source\TestDifferentDisplays::prepareViewDisplay()
  3. 10 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php \Drupal\media_test_source\Plugin\media\Source\TestDifferentDisplays::prepareViewDisplay()

Overrides MediaSourceBase::prepareViewDisplay

File

core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php, line 27

Class

TestDifferentDisplays
Provides test media source.

Namespace

Drupal\media_test_source\Plugin\media\Source

Code

public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
    parent::prepareViewDisplay($type, $display);
    $source_name = $this->getSourceFieldDefinition($type)
        ->getName();
    $source_component = $display->getComponent($source_name) ?: [];
    $source_component['type'] = 'entity_reference_entity_id';
    $display->setComponent($source_name, $source_component);
}

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