function MediaSourceBase::getSourceFieldOptions
Same name in other branches
- 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldOptions()
- 8.9.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getSourceFieldOptions()
- 10 core/modules/media/src/MediaSourceBase.php \Drupal\media\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
File
-
core/
modules/ media/ src/ MediaSourceBase.php, line 159
Class
- MediaSourceBase
- Base implementation of media source plugin.
Namespace
Drupal\mediaCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.