Follow up to #2899553: Architectural review of the Workflows module (documentation cleanups). WorkflowTypeInterface.2
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 2900046-20.patch | 9.77 KB | amateescu |
| #17 | 2900046-17.patch | 9.78 KB | wim leers |
| #15 | 2900046-15.patch | 9.9 KB | timmillwood |
| #15 | interdiff-2900046-15.txt | 3.05 KB | timmillwood |
| #8 | 2900046-8.patch | 7.67 KB | timmillwood |
Comments
Comment #2
sam152 commentedComment #3
wim leersThis is the API change.
Is this ?
Comment #4
wim leersIf it's optional, then how can you ensure it is passed?
Shouldn't
$entitybe required?Comment #5
sam152 commentedI agree on critical status.
Currently $entity is not part of the workflows interface because we can't assume all workflow types are necessarily going to be concerned with entities at all, those are semantics that content_moderation introduces. Thus
$entitybecame an optional parameter, so that we're still satisfying the original interface.Within content_moderation, for all places where we have instances of an entity and the plugin, we're able to get a more contextually-relevant default state. For other consumers of the api, in the cases where they want to use this method, we don't assume an entity is present, the param can be omitted and a return value is falls back to a sane default, still honouring the contract of the interface.
Comment #6
wim leers#5: Thanks for that explanation! That's then something we should document in both Workflows' API docs ("is not tied to entities") and Content Moderation's docs ("is tied to content entities").
Comment #7
wim leersComment #8
timmillwoodAdding some inline docs to
\Drupal\content_moderation\Plugin\WorkflowType\ContentModeration::getInitialStateto explain why we are passing in $entity and what we're doing with it.This should be ready for RTBC now, the code from @Sam152 looks perfect to me, this would be a nice parameter to remove.
Comment #9
wim leersgetInitialState()by the Content Moderation module's code MUST pass the$entityparameter.workflows.api.phpandcontent_moderation.api.php.getInitialState(EntityInterface $entity)the actual API? Then we don't need to deal with any of these ambiguities. In other words, I'm questioningComment #10
sam152 commented#9.3, at this point it'd be the first touch point that makes any such assumption. I think it would be a shame to introduce this coupling, at the expense of flexibility when:
Happy to add the other suggested docs. Is that in scope for this issue?
Comment #11
wim leersSince Drupal's all about entities, I think it's reasonable to limit to entities. That's also what https://www.drupal.org/project/jsonapi did, which allowed it to become significantly simpler (the benefit/impact here is much smaller obviously, we're talking about a single API method).
However, it seems you're strongly convinced that there are use cases beyond entities :) I respect your opinion as the module maintainer of course. I'm merely trying to help you make your maintainer life as simple as possible!
I think it is, because the lack of clarity around this is the entire reason this issue was spawned!
Comment #12
timmillwoodWe could throw an exception and/or trigger_error if
$entityis not set?I would not want to make
$entitya required field in Workflows without passing it by @alexpott who lead the work on splitting it out of Content Moderation. If we are making workflows entity specific we might as well merge the two modules back together.Comment #13
wim leersSee, I didn't know about that background/history! :)
My key concern is that some people end up interacting with Workflows' API, and expect it to work also for Content Moderation. But the Workflows API specifies you don't need to pass
$entitytogetInitialState(). So this is confusing/somewhat contradicting.But it sounds like this was already discussed. Which issues should I read to understand how we arrived at the current architecture?
Comment #14
timmillwoodWorkflows was introduced in #2779647: Add a workflow component, ui module, and implement it in content moderation.
The
$entityparam was added togetInitialState()in #2817835: When enabling moderation apply a relative state.Comment #15
timmillwoodComment #16
timmillwoodAdding the two api.php files, and throwing an exception if the $entity in getInitialState() is not an instance of ContentEntityInterface.
Comment #17
wim leers+1
s/it's/its/
s/own/own,/
s/stand alone/stand-alone/
Fixed these nits (and a few more), and RTBC'd!
Comment #19
wim leersComment #20
amateescu commentedRerolled :)
Comment #21
wim leersLooks like this was committed to 8.5.x but the issue was not updated: http://cgit.drupalcode.org/drupal/commit/?id=d4165ff1085da979f52b23a9d8f...
Comment #22
sam152 commentedI think the commit message got messed up and thus hasn't updated the issue:
Comment #23
wim leersD'oh, right.
But that's only been committed to 8.5.x anyway, we still need this to be committed to 8.4.x. So actually the state of this issue is still accurate :)
Comment #24
wim leersNope, I'm wrong — it's since been cherry-picked: http://cgit.drupalcode.org/drupal/commit/?id=7da23b0bbf0a55dd54fc7a352f9... — hurray!
Comment #25
wim leersThis still needs a change record though.
I don't think it makes sense to add this change to the existing https://www.drupal.org/node/2897706 change record, since it's independent from that change set.
Comment #26
sam152 commentedAdded the CR, currently in a draft. Feel free to review/edit or publish.
Comment #27
larowlanPublished the CR