Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change key to use when looking up entities #94

Closed
wants to merge 1 commit into from
Closed

Change key to use when looking up entities #94

wants to merge 1 commit into from

Conversation

TLyngeJ
Copy link

@TLyngeJ TLyngeJ commented Jul 14, 2016

I've changed the identifier to use, when looking up entities, in Drupal/Driver/Fields/Drupal8/EntityReferenceHandle:expand() from label to id.

Not sure why label was used. Anyway, didn't work and this one seems to.

@jonathanjfshaw
Copy link
Contributor

I think label is used so that steps can reference existing entities by their label, rather than a numeric id which is less natural for step authors.

@pfrenssen pfrenssen added this to the 2.0 milestone Jan 3, 2017
@pfrenssen
Copy link
Collaborator

This is correct, we shouldn't use the label here but the entity ID. This was probably added as part of a Behat use case as @jonathanjfshaw suggests, but in the scope of DrupalDriver it doesn't make sense to use labels.

So yeah we need to fix this but the problem is that this breaks backwards compatibility. All current code relies on the value being a label. Marking this for the 2.x milestone.

@pfrenssen pfrenssen added the bug label Jan 3, 2017
@TLyngeJ
Copy link
Author

TLyngeJ commented Jan 3, 2017

How about, in the mean time, try and load the entity ID, if that returns nothing, try and look up the entity by it's label?

@pfrenssen
Copy link
Collaborator

OK I like this idea! That would work without breaking backwards compatibility.

@kmcculloch
Copy link

I just want to give this patch a bump. I'm trying to use the driver to create nodes with an entity reference field that points to users, and the entity definition object for users does not contain a "label" key. Apparently "id" is the only key that's guaranteed to be there: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityType.php/function/EntityType%3A%3AgetKeys/8.2.x

@jonathanjfshaw
Copy link
Contributor

See also See also #117 and #133 for discussions addressing this problem

@jonathanjfshaw
Copy link
Contributor

@pfrenssen

but in the scope of DrupalDriver it doesn't make sense to use labels.

It seems that the whole point of the current field handlers is to convert from natural language strings into Drupal-friendly variables ready to be set in Drupal fields. What you're saying here would seem to imply that the whole field handler mechanism should be moved into the Drupal extension. Or am I missing something?

@jhedstrom
Copy link
Owner

Is this resolved now that #117 is merged?

@jonathanjfshaw
Copy link
Contributor

Not necessarily, there's a bigger architectural issue here about how responsibilities are divided.

@jhedstrom
Copy link
Owner

#241 was merged. Thanks all!

@jhedstrom jhedstrom closed this Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants