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

Breadcrumb

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

function MediaSourceBase::getSourceFieldDefinition

Overrides MediaSourceInterface::getSourceFieldDefinition

File

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

Class

MediaSourceBase
Base implementation of media source plugin.

Namespace

Drupal\media

Code

public function getSourceFieldDefinition(MediaTypeInterface $type) {
    // Nothing to do if no source field is configured yet.
    $field = $this->configuration['source_field'];
    if ($field) {
        // Even if we do know the name of the source field, there is no
        // guarantee that it already exists.
        $fields = $this->entityFieldManager
            ->getFieldDefinitions('media', $type->id());
        return $fields[$field] ?? NULL;
    }
    return NULL;
}

API Navigation

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