function TestDifferentDisplays::prepareViewDisplay
Overrides MediaSourceBase::prepareViewDisplay
File
- 
              core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ TestDifferentDisplays.php, line 24  
Class
- TestDifferentDisplays
 - Provides test media source.
 
Namespace
Drupal\media_test_source\Plugin\media\SourceCode
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.