Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MediaSourceBase.php

function MediaSourceBase::getSourceFieldOptions

Get the source field options for the media type form.

This returns all fields related to media entities, filtered by the allowed field types in the media source annotation.

Return value

string[] A list of source field options for the media type form.

1 call to MediaSourceBase::getSourceFieldOptions()
MediaSourceBase::buildConfigurationForm in core/modules/media/src/MediaSourceBase.php
Form constructor.

File

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

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

protected function getSourceFieldOptions() {
    // If there are existing fields to choose from, allow the user to reuse one.
    $options = [];
    foreach ($this->entityFieldManager
        ->getFieldStorageDefinitions('media') as $field_name => $field) {
        $allowed_type = in_array($field->getType(), $this->pluginDefinition['allowed_field_types'], TRUE);
        if ($allowed_type && !$field->isBaseField()) {
            $options[$field_name] = $field->getLabel();
        }
    }
    return $options;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal