public static function MediaHelper::getSourceField in Varbase Media 9.0.x
Same name and namespace in other branches
- 8.7 modules/entity_browser_generic_embed/src/MediaHelper.php \Drupal\entity_browser_generic_embed\MediaHelper::getSourceField()
- 8.5 modules/entity_browser_generic_embed/src/MediaHelper.php \Drupal\entity_browser_generic_embed\MediaHelper::getSourceField()
- 8.6 modules/entity_browser_generic_embed/src/MediaHelper.php \Drupal\entity_browser_generic_embed\MediaHelper::getSourceField()
Returns the media entity's source field item list.
Parameters
\Drupal\media\MediaInterface $entity: The media entity.
Return value
\Drupal\Core\Field\FieldItemListInterface|null The media entity's source field item list, or NULL if the media type plugin does not define a source field.
3 calls to MediaHelper::getSourceField()
- MediaForm::form in modules/
entity_browser_generic_embed/ src/ Form/ MediaForm.php - Gets the actual form array to be built.
- MediaHelper::createFromInput in modules/
entity_browser_generic_embed/ src/ MediaHelper.php - Creates a media entity from an input value.
- MediaHelper::useFile in modules/
entity_browser_generic_embed/ src/ MediaHelper.php - Attaches a file entity to a media entity.
File
- modules/
entity_browser_generic_embed/ src/ MediaHelper.php, line 230
Class
- MediaHelper
- Provides helper methods for dealing with media entities.
Namespace
Drupal\entity_browser_generic_embedCode
public static function getSourceField(MediaInterface $entity) {
$field = $entity
->getSource()
->getSourceFieldDefinition($entity->bundle->entity);
return $field ? $entity
->get($field
->getName()) : NULL;
}