Problem/Motivation

The host entity type and bundle may not be hard-coded as it's currently the case in:
https://git.drupalcode.org/project/vidstack_player/-/blob/1.x/src/Plugin...

Instead the field ($this) needs to be asked for the host entity, I think? Or am I missing something here?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anybody created an issue. See original summary.

anybody’s picture

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?

anybody’s picture

Assigned: lrwebks » grevil
anybody’s picture

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?

Anyway through https://api.drupal.org/api/drupal/core%21modules%21file%21src%21Plugin%2... that part might be correct.

grevil made their first commit to this issue’s fork.

grevil’s picture

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.

anybody’s picture

Status: Active » Needs review

@grevil re #6 LGTM so far... let's keep this for now.

grevil’s picture

Assigned: grevil » anybody

Ok, please review then!

anybody’s picture

Assigned: anybody » Unassigned
Status: Needs review » Reviewed & tested by the community

Nice!

anybody’s picture

Status: Reviewed & tested by the community » Fixed

  • anybody committed ebffeea7 on 1.x authored by grevil
    Issue #3521009: Host entity type / bundle may not be "media/video" hard-...
grevil’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.