so as part of my work on refactoring I started working on a relative resolvers to ResourceReference and in the ends it appeared that I needed a supplementary information in EntityReference when it’s relative, to know how to properly resolve it.
@tmortagne managed after a long discussion to explain to me that the info we need is for the resolver to be able to properly perform the resolution by selecting the proper parts in the base reference. And he proposed that instead of providing an artificial boolean value API in EntityReference we’d provide instead a new method EntityType getParentType() which would avoid letting the resolvers to compute that info, and which could be set when creating the reference.
We also agreed that best for storing that information would be the parameters of the EntityReference, since we always have all mechanism to serialize/parse those, and we already do that for the Locale in some references.
Regarding the name of the key for the parameter I propose to use parentType as we use locale for the locale key parameter.
So the 3 questions are:
Do you agree with adding a new method getParentType() in EntityReference?
Do you agree with storing that in the map of parameters using parentType as key?
Do you agree about backporting those changes in future LTS (16.10.x)?
Question 3 is because all this work is originally done for fixing Loading...
I’m wondering about the naming, in particular for the parameter. I find the naming a bit misleading as this parameter is only used when the parent is null. Wouldn’t something like fallbackParentType be better? Also, I’m wondering if something similar couldn’t be achieved by setting some kind of “unresolved” reference with a specified type but unspecified name as parent (but this might not work with serializers).
In general, +1, I’m just not sure if the naming is the best.
In your case, the entity reference just doesn’t have any parent I assume (otherwise, the parameter wouldn’t be used). However, what if you just use a special UnresolvedEntityReference as parent that has the entity type you want? Now, as I said, this might not work with serialization, so your solution might be more robust.
ok thanks for clarification. Indeed it might be a bit more elegant, but we’d need to rework serialization, while using parameters we don’t have anything to do for that.