You are here

public function Image::createSourceField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/media/Source/Image.php \Drupal\media\Plugin\media\Source\Image::createSourceField()
  2. 9 core/modules/media/src/Plugin/media/Source/Image.php \Drupal\media\Plugin\media\Source\Image::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 File::createSourceField

File

core/modules/media/src/Plugin/media/Source/Image.php, line 155

Class

Image
Image entity media source.

Namespace

Drupal\media\Plugin\media\Source

Code

public function createSourceField(MediaTypeInterface $type) {

  /** @var \Drupal\field\FieldConfigInterface $field */
  $field = parent::createSourceField($type);

  // Reset the field to its default settings so that we don't inherit the
  // settings from the parent class' source field.
  $settings = $this->fieldTypeManager
    ->getDefaultFieldSettings($field
    ->getType());
  return $field
    ->set('settings', $settings);
}