function AddFormBase::getSourceFieldName

Same name in other branches
  1. 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getSourceFieldName()
  2. 10 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getSourceFieldName()
  3. 11.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getSourceFieldName()

Returns the name of the source field for a media type.

Parameters

\Drupal\media\MediaTypeInterface $media_type: The media type to get the source field name for.

Return value

string The name of the media type's source field.

3 calls to AddFormBase::getSourceFieldName()
AddFormBase::buildEntityFormElement in core/modules/media_library/src/Form/AddFormBase.php
Builds the sub-form for setting required fields on a new media item.
AddFormBase::processInputValues in core/modules/media_library/src/Form/AddFormBase.php
Creates media items from source field input values.
FileUploadForm::buildEntityFormElement in core/modules/media_library/src/Form/FileUploadForm.php
Builds the sub-form for setting required fields on a new media item.

File

core/modules/media_library/src/Form/AddFormBase.php, line 793

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

protected function getSourceFieldName(MediaTypeInterface $media_type) {
    return $media_type->getSource()
        ->getSourceFieldDefinition($media_type)
        ->getName();
}

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