You are here

public function MediaSourceBase::createSourceField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::createSourceField()
  2. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::createSourceField()
2 methods override MediaSourceBase::createSourceField()
File::createSourceField in core/modules/media/src/Plugin/media/Source/File.php
Creates the source field definition for a type.
OEmbed::createSourceField in core/modules/media/src/Plugin/media/Source/OEmbed.php
Creates the source field definition for a type.

File

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

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function createSourceField(MediaTypeInterface $type) {
  $storage = $this
    ->getSourceFieldStorage() ?: $this
    ->createSourceFieldStorage();
  return $this->entityTypeManager
    ->getStorage('field_config')
    ->create([
    'field_storage' => $storage,
    'bundle' => $type
      ->id(),
    'label' => $this->pluginDefinition['label'],
    'required' => TRUE,
  ]);
}