You are here

public function MediaSourceBase::prepareViewDisplay in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::prepareViewDisplay()

Prepares the media type fields for this source in the view display.

This method should normally call \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent() or \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to configure the media type fields in the view display.

Parameters

\Drupal\media\MediaTypeInterface $type: The media type which is using this source.

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The display which should be prepared.

Overrides MediaSourceInterface::prepareViewDisplay

See also

\Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent()

\Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent()

2 calls to MediaSourceBase::prepareViewDisplay()
Image::prepareViewDisplay in core/modules/media/src/Plugin/media/Source/Image.php
Prepares the media type fields for this source in the view display.
TestDifferentDisplays::prepareViewDisplay in core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php
Prepares the media type fields for this source in the view display.
6 methods override MediaSourceBase::prepareViewDisplay()
AudioFile::prepareViewDisplay in core/modules/media/src/Plugin/media/Source/AudioFile.php
Prepares the media type fields for this source in the view display.
Image::prepareViewDisplay in core/modules/media/src/Plugin/media/Source/Image.php
Prepares the media type fields for this source in the view display.
OEmbed::prepareViewDisplay in core/modules/media/src/Plugin/media/Source/OEmbed.php
Prepares the media type fields for this source in the view display.
TestDifferentDisplays::prepareViewDisplay in core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestDifferentDisplays.php
Prepares the media type fields for this source in the view display.
TestWithHiddenSourceField::prepareViewDisplay in core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithHiddenSourceField.php
Prepares the media type fields for this source in the view display.

... See full list

File

core/modules/media/src/MediaSourceBase.php, line 345

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
  $display
    ->setComponent($this
    ->getSourceFieldDefinition($type)
    ->getName(), [
    'label' => 'visually_hidden',
  ]);
}