data-entity-id currently overrides data-entity-uuid if both present for a given node:

// from EntityEmbedFilter::process()
if ($node->hasAttribute('data-entity-uuid')) {
  // ....
}
if ($node->hasAttribute('data-entity-id')) {
  //....
}

Since we encourage UUID usage we probably want the opposite. Something like this:

// from EntityEmbedFilter::process()
if ($node->hasAttribute('data-entity-uuid')) {
  // ....
}
elseif ($node->hasAttribute('data-entity-id')) {
  //....
}

Also, UUID is being added into DOM if ID is being used. AFAIK this is not actually saved, so I don't see real point in doing that. Can we simply kill that part of the code?

// Add the entity UUID.
if ($entity && $uuid = $entity->uuid()) {
  $node->setAttribute('data-entity-uuid', $uuid);
}

Comments

cs_shadow’s picture

Status: Active » Needs review

In my PR (https://github.com/drupal-media/entity_embed/pull/7/), data UUID is given preference over ID as mentioned above.

Reg. the 2nd point, the UUID is actually appended to the parent DOM node beacuse the changes actually get saved. Hence, its not required to kill that code.

cs_shadow’s picture

Assigned: Unassigned » cs_shadow
slashrsm’s picture

Status: Needs review » Needs work

Let's split PRs as also mentioned in #2269135: Should embedded entity replace existing content.

cs_shadow’s picture

Status: Needs work » Needs review

Splitted PRs, #7 and #8.

slashrsm’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

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