You are here

public function MediaSourceBase::getSourceFieldDefinition in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
  2. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
9 calls to MediaSourceBase::getSourceFieldDefinition()
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::prepareFormDisplay in core/modules/media/src/Plugin/media/Source/OEmbed.php
Prepares the media type fields for this source in the form 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::prepareFormDisplay 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 form display.

... See full list

File

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

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function getSourceFieldDefinition(MediaTypeInterface $type) {

  // Nothing to do if no source field is configured yet.
  $field = $this->configuration['source_field'];
  if ($field) {

    // Even if we do know the name of the source field, there is no
    // guarantee that it already exists.
    $fields = $this->entityFieldManager
      ->getFieldDefinitions('media', $type
      ->id());
    return $fields[$field] ?? NULL;
  }
  return NULL;
}