Member-only story
Adjusting a node’s published time when publishing through content moderation
I use the Content Moderation module on my personal site to managed my publication workflow. One of my pet peeves if when I accidentally forget to adjust a blog post’s creation timestamp once published. Sometimes it is only a few hours old, sometimes it is a week. I finally sat down to fix this small annoyance. Only to find out fixing it wasn’t as simple as I would have thought.
I am fairly used to working with the State Machine module, as it is a backbone in Drupal Commerce for order workflows. We have Workflows, States, and Transitions in State Machine, along with a field type. Whenever a state field changes, it must fit into an available transition. We then dispatch events to the system for these transitions.
The Drupal core modules Workflows has the same concept of Workflows, States, and Transitions. However, the Content Moderation module adds a UI and field components for Workflows. There are also no events. I was hoping I could just write an event subscriber and bam, be done. But, that’s not what happened and why I am writing this blog.
Why the difference? When we first began reviewing our workflow requirements, I remember Bojan sat with the Workbench and Content Moderation folks to try and harmonize efforts. Unfortunately we couldn’t reconcile a few differences, and we went with creating an 8.x branch for State Machine and Drupal core went on its own path.