If state changes are entities then fields can be put on them.

This is one of the features discussed at http://groups.drupal.org/node/198188

I am going to close a Workbench Moderation issue as a duplicate of this one. #1294880: Convert Workbench Moderation records to entities

Comments

stevector’s picture

Here's a start on this work. I'll post two patches, one against 7.x-2.x and one against #1412742: Refactor State Flow to be entity type agnostic (Rename state_flow to state_flow_node).

There are still plenty of open questions here like:

What should this entity type be called?
-I'm currently going with state_flow_history_entity. Perhaps it's overly verbose. For now it makes testing a little easier.

What role should bundles play?
-I could see bundles (and therefore fields) changing based on the workflow being used. So the workflow used by Article nodes might need a bunch of fields on it's state flow history entity. These fields could track the next relevant user with a user ref field and checkboxes for whether the Article has been cleared by the Legal and Marketing departments. Blog nodes might only need the Log textarea that is already in State Flow 7.x-1.x. So the node type would determine which workflow is used and the workflow determines which state_flow_history_entity bundle is needed. I think this approach would work fine with what I'm doing in http://drupal.org/sandbox/stevector/1405838

stevector’s picture

stevector’s picture

I'm attaching a sample feature that this patch makes possible. It attaches a user ref field to the state_flow_history_entity. It also provides a rule that sends an email to the user referenced in the field when the state change occurs.

stevector’s picture

Status: Active » Needs review
yeha’s picture

Hi Steve,

I'm reviewing the code now, but I have a question about the following:

So the node type would determine which workflow is used and the workflow determines which state_flow_history_entity bundle is needed.

Does it also means that multiple node types can use the same workflow but each of the node type can have different state_flow_history_entity bundle as required?

stevector’s picture

yeha,

Thanks for reviewing! Currently in that patch there state_flow_history_entity has only one bundle. I think it is an open question how the bundle would vary if there were than one.

In the scenario I describe in #1, state_flow_history_entity bundles would vary on the same conditions as the workflow so if two node types used the same workflow, they would also use the same state_flow_history_entity bundle.

Since none of that code is written, it could work on a different model. Perhaps bundle should be selected completely independent of workflow.

yeha’s picture

I've been working with the 7.x-1.x for awhile to extend it for my needs but it's getting to a point that I'm rewriting a lot of the state_flow module instead of just "massaging" it.

From what I understood, the selection of which workflow to use will be determined by the properties/fields on the node (entity in the future?). Within the node, there's lots of choices, node type is the logical choice but it's not limited to that. One can basically use anything from node to make the decision.

With that said, the state_flow_history_entity bundle should work the same way. Given the node (entity) or workflow (state machine object?), one can use it to determine which bundle to use.

I hope I am somewhat making sense :)

stevector’s picture

Yes yeha, #7 makes sense.

I would add that the workflow could also also vary based on the values in the state_flow_history_entity itself. A commonly requested use case is "approval checkboxes." An organization may need a blog post to be "marketing approved," and "508 compliant." Those could be checkbox fields on the state_flow_history_entity and the workflow/events/states could prevent the a node from moving to a state like Published until all those boxes are checked.

It would be problematic if the workflow looked for a certain checkbox field but the state_flow_history_entity bundle in use didn't have that field. Of course the UI could give warning messages to protect against that situation and site-builders will always figure out ways to shoot themselves in the foot.

fmitchell’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

Moving this request to 7.x-3.x branch

stevector’s picture

Title: Make state change records themselves be entities » Make state change records themselves be entities with bundles
Status: Needs review » Active

State change records as entities is in 3.x. There is currently no bundle support. Switching back to active.

elijah lynn’s picture

Issue summary: View changes
Status: Active » Needs work

Setting to needs work as that seems more accurate.

elijah lynn’s picture