Let's add EntityInterface::uuid(). If we decide to go for UUIDs instead of regular IDs later on, we can still remove that method then.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Issue tags: +UUID
sun’s picture

Title: add a method for getting an entity's uuid » Add method for getting an entity's UUID
Berdir’s picture

Status: Active » Needs review
FileSize
3.09 KB

Here we go.

Status: Needs review » Needs work

The last submitted patch, entity-uuuid-method-1720784-3.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
3.63 KB

Forgot one part of the patch.

ygerasimov’s picture

Component: entity system » search.module

Patch looks good to me. I am not sure if I can mark this issue as RTBC.

ygerasimov’s picture

Component: search.module » entity system
corvus_ch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me too.

plach’s picture

+++ b/core/modules/entity/lib/Drupal/entity/Entity.php
@@ -66,6 +66,13 @@ class Entity implements EntityInterface {
+    return isset($this->uuid) ? $this->uuid : NULL;

Shouldn't this use the uuid entity key?

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Comimtted/pushed to 8.x.

Berdir’s picture

@plach: The reason for hardcoding uuid is to be performant, just like id(). If you have a differently named column for the uuid, you need to override the method. Open to discuss that, though.

I also added a sentence about the new method to the already existing change notice that is already linked to this issue.

plach’s picture

No need for discussion here. I'm totally for blowing away entity keys in favor of method overrides, I just thought we were using entity keys for the UUID elsewhere.

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