- Issue created by @Anybody
- 🇩🇪Germany Anybody Porta Westfalica
I guess something like
// Get the field definition. $field_definition = $this->getFieldDefinition(); // Retrieve the entity type ID and bundle. $entity_type = $field_definition->getTargetEntityTypeId(); $bundle = $field_definition->getTargetBundle();
might be needed?
- 🇩🇪Germany Anybody Porta Westfalica
I'm also unsure why this hard-coded implementation exists:
/** * {@inheritdoc} */ public static function getMediaType() { return 'video'; }
but didn't check it deeper, yet. Please do that. Maybe because by FileMediaFormatterBase this is more than just a file formatter... mhm. Anyway, if a custom "myvideo" media type exists with a video field, it should also work, but hard-coding would break it, right?
- First commit to issue fork.
- 🇩🇪Germany Grevil
Also, I am a bit unsure, when the Remote Formatter should be applicable:
public static function isApplicable(FieldDefinitionInterface $field_definition) { if ($field_definition->getTargetEntityTypeId() !== 'media') { return FALSE; } if (parent::isApplicable($field_definition)) { $media_type = $field_definition->getTargetBundle(); if ($media_type) { $media_type = MediaType::load($media_type); return $media_type && $media_type->getSource() instanceof OEmbedInterface; } } return FALSE; }
Especially the "OEmbedInterface" part makes this very restricted to use.
- @grevil opened merge request.