function MediaSourceBase::getSourceFieldDefinition
Same name in other branches
- 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
- 10 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
- 11.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldDefinition()
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.