You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
you don't need use new entity class you can just use hook_entity_base_field_info_alter to add the status field. It looks like you just add getter/settings methods to the entity class. You don't need specific getter/setter methods you can just access the status field like any other base field.
The text was updated successfully, but these errors were encountered:
I initially used hook_entity_base_field_info, see the repo before the last commit. I was not using the alter version of this hook, because i was adding a not existing field, not altering an existing field and i read that for this case the alter hook should not be used, which makes sense i guess.
But the reason why i chose not to use that approach and use an extended entity class instead, was to have the posibility to use the isPublished() method. That way i would replicate the node enitites functioning. When i had decided to go with my own extended Term class i also added the getter/setter methods for added simplicity.
So this brings me back to my original question on IRC and Slack - is there a way to add a method to the entity class without extending it? Because i agree with you that for the simple status field forcing to use a custom extended entity class seems to be a bit too much.
Berdir answered me on Slack saying that this is not possible and also pointed out that there is work going on to make the Term entity work more like Node, making this module unnecessary for D8 in the future. Hopefully this issue gets commited to 8.5, making this module a fallback possibility for people stuck with versions below 8.5 for some reason.
Still, thanks for taking the time for the feedback and if you can think of a better way to achieve my goal, i am more than happy to implement it!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
@ainarend saw you question on irc
you don't need use new entity class you can just use
hook_entity_base_field_info_alter
to add the status field. It looks like you just add getter/settings methods to the entity class. You don't need specific getter/setter methods you can just access the status field like any other base field.The text was updated successfully, but these errors were encountered: