Closed (works as designed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
content_moderation.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
15 Mar 2017 at 17:18 UTC
Updated:
17 May 2017 at 20:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jhedstromI left the
getCurrentUserId()method off of the interface since that is a default value callback specific to the implementation. This probably needs some tests, but its a start.Comment #3
jhedstromThat last patch had an error where the interface referenced the implementation. As I fixed this though, I noticed that this method presumably is not used anywhere:
since it's calling a protected method there...
Comment #4
sam152 commentedThis is an interesting one. I don't really feel like the ContentModerationState should be the go-to way of interacting with the moderation states, all of that should be done through the computed field if possible. Adding methods to the interface would encourage it as a part of the public API. It raises the question if that whole entity type should be @internal. Or at least there should be a review of the methods to see what should be internal or not, getCurrentUserId seems like a candidate.
Is this use case based on the result of an entity query, or something similar? Maybe we can provide some wrapper around these kind of queries to abstract the details of the underlying entity away. I wonder how hard it would be to make entity query work to join against content_moderation_state so you could simply go
->condition('moderation_state', 'draft');on a node entity query for example.Also, you can call protected methods on objects if the method doing the calling is on the same class the protected method is on, even if the entity !== $this.
Comment #5
timmillwoodI mostly agree with #4, content_moderation_state entity shouldn't be where you go to interact with moderation states, and maybe we should mark it as @internal.
The content_moderation_state entity is sometimes useful when wanting a list of all "archived" entities across different entity types, which I hope we'll be able to do in Views, but other than that you should come via the computed moderation_state field.
Maybe we should remove the
ContentModerationStateInterface?Comment #6
jhedstromIt's utilized in
hook_ENTITY_TYPE_updateto generate notifications of state change for content--is there a better way to hook into that process?Comment #7
timmillwood@jhedstrom - That is the best way, Workbench Moderation used to fire an event, but when we switched to use a content entity for storage there was no need for the event as we have a hook. So I guess for this use case it kinda makes sense.
Comment #8
sam152 commented@jhedstrom, how would you feel about doing something like #2873287: Dispatch events for changing content moderation states instead? It would be part of the effort to ensure people don't have to understand and interact with the ContentModerationState entity directly. I think it'll be marked @internal at some point and we're already doing things like #2779931, which deny all access to it for CRUD purposes.
Comment #9
jhedstrom@Sam152 I think that would be ok. However, as long as this is an entity, folks will find a way to do something crazy with it directly ;)
Comment #10
jhedstromClosing in favor of #2873287: Dispatch events for changing content moderation states.