Updated: Comment #N
Problem/Motivation
Hal uses setter injection from the NormalizerBase class. These are setLinkManager, and setEntityResolver. So some or all of these are being used for some of the services that extend this class. Also FieldNormalizer and FieldItemNormalizer do not need these but the link manager is being set on these too.
This makes it much more confusing to determine the dependencies for these services. These are also required dependencies, and don't need to be synchronized etc.. So setter injection doesn;t makes much sense.
Proposed resolution
Switch to constructor injection and pass the dependencies in as services instead.
Remaining tasks
Patch, reviews.
User interface changes
None
API changes
Removal of setLinkManager/setEntityResolver methods on hals NormalizerBase class. I would be very surprised if anyone (except maybe Lin) was extending any of these :)
Comment | File | Size | Author |
---|---|---|---|
d8.hal-constructors.patch | 7.93 KB | damiankloip | |
Comments
Comment #1
dawehnerEspecially the required bit is quite important. You want to make it as simple as possible.
Comment #2
alexpottMakes sense. Committed c3b1273 and pushed to 8.x. Thanks!
Comment #3
jessebeach CreditAttribution: jessebeach commentedI'm not yet sure if it's related, but I just found this #2187413: GET request for an entity via application/hal+json throws a fatal error in service "current_user".
I'm going to attempt a bisect to see if I can find the commit that broke this behavior.
Comment #4
jessebeach CreditAttribution: jessebeach commentedMy issue referenced in #3 is a duplicate of #2182055: Comment module causes Circular reference error on a REST request.