public function MediaSourceBase::createSourceField in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::createSourceField()
Creates the source field definition for a type.
Parameters
\Drupal\media\MediaTypeInterface $type: The media type.
Return value
\Drupal\field\FieldConfigInterface The unsaved field definition. The field storage definition, if new, should also be unsaved.
Overrides MediaSourceInterface::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\mediaCode
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,
]);
}