You are here

public function OEmbed::prepareFormDisplay in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/media/Source/OEmbed.php \Drupal\media\Plugin\media\Source\OEmbed::prepareFormDisplay()

Prepares the media type fields for this source in the form 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 form display.

Parameters

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

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

Overrides MediaSourceBase::prepareFormDisplay

See also

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

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

File

core/modules/media/src/Plugin/media/Source/OEmbed.php, line 503

Class

OEmbed
Provides a media source plugin for oEmbed resources.

Namespace

Drupal\media\Plugin\media\Source

Code

public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display) {
  parent::prepareFormDisplay($type, $display);
  $source_field = $this
    ->getSourceFieldDefinition($type)
    ->getName();
  $display
    ->setComponent($source_field, [
    'type' => 'oembed_textfield',
    'weight' => $display
      ->getComponent($source_field)['weight'],
  ]);
  $display
    ->removeComponent('name');
}