public function MediaSourceBase::getSourceFieldDefinition in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
Get the source field definition for a media type.
Parameters
\Drupal\media\MediaTypeInterface $type: A media type.
Return value
\Drupal\Core\Field\FieldDefinitionInterface|null The source field definition, or NULL if it doesn't exist or has not been configured yet.
Overrides MediaSourceInterface::getSourceFieldDefinition
File
- core/
modules/ media/ src/ MediaSourceBase.php, line 269
Class
- MediaSourceBase
- Base implementation of media source plugin.
Namespace
Drupal\mediaCode
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 isset($fields[$field]) ? $fields[$field] : NULL;
}
return NULL;
}