function MediaSourceBase::prepareFormDisplay

Same name in other branches
  1. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::prepareFormDisplay()
  2. 10 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::prepareFormDisplay()
  3. 11.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::prepareFormDisplay()

Overrides MediaSourceInterface::prepareFormDisplay

2 calls to MediaSourceBase::prepareFormDisplay()
OEmbed::prepareFormDisplay in core/modules/media/src/Plugin/media/Source/OEmbed.php
Prepares the media type fields for this source in the form 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.
3 methods override MediaSourceBase::prepareFormDisplay()
OEmbed::prepareFormDisplay in core/modules/media/src/Plugin/media/Source/OEmbed.php
Prepares the media type fields for this source in the form 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.
TestWithHiddenSourceField::prepareFormDisplay 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 form display.

File

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

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display) {
    // Make sure the source field is placed just after the "name" basefield.
    $name_component = $display->getComponent('name');
    $source_field_weight = $name_component && isset($name_component['weight']) ? $name_component['weight'] + 5 : -50;
    $display->setComponent($this->getSourceFieldDefinition($type)
        ->getName(), [
        'weight' => $source_field_weight,
    ]);
}

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