-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OPENEUROPA-1915: Integrate entity_versions module in oe_editorial #30
Conversation
@@ -151,7 +151,10 @@ function oe_editorial_corporate_workflow_form_content_moderation_entity_moderati | |||
function _oe_editorial_corporate_workflow_moderation_submit(array &$form, FormStateInterface &$form_state): void { | |||
/** @var \Drupal\oe_editorial_corporate_workflow\Services\ShortcutRevisionHandler $shortcut_handler */ | |||
$shortcut_handler = \Drupal::service('oe_editorial_corporate_workflow.shortcut_transition_handler'); | |||
$shortcut_handler->createShortcutRevisions($form_state->getValue('new_state'), $form_state->get('entity'), $form_state->getValue('revision_log')); | |||
$latest_entity = $shortcut_handler->createShortcutRevisions($form_state->getValue('new_state'), $form_state->get('entity'), $form_state->getValue('revision_log')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's call this $latest_revision
$shortcut_handler->createShortcutRevisions($form_state->getValue('new_state'), $form_state->get('entity'), $form_state->getValue('revision_log')); | ||
$latest_entity = $shortcut_handler->createShortcutRevisions($form_state->getValue('new_state'), $form_state->get('entity'), $form_state->getValue('revision_log')); | ||
|
||
// Make sure we pass along the updated entity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the shortcut, we are creating revisions for all of the transitions we are skipping. The last transition in the chain is handled by core so we need to make sure that its submit handler receives the latest revision that we created. Otherwise it may use a revision with stale data.
*/ | ||
public function createShortcutRevisions(string $target_state, ContentEntityInterface $entity, string $revision_message = NULL); | ||
public function createShortcutRevisions(string $target_state, ContentEntityInterface $entity, string $revision_message = NULL): RevisionableInterface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityInterface
not RevisionableInterface
.
->addEntityVersionFieldToWorkflowBundles('oe_corporate_workflow', $default_values); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This post update is not needed.
// Get bundles associated with the corporate workflow and assign the | ||
// entity version field to them. | ||
$workflow_name = 'workflows.workflow.' . $workflow_id; | ||
$corporate_workflow = $this->configFactory->getEditable($workflow_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't know it's the corporate workflow.
'entity_type' => 'node', | ||
'field_name' => 'version', | ||
'bundle' => $bundle, | ||
'label' => 'Version', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translatable.
tests/Behat/FeatureContext.php
Outdated
$node = reset($nodes); | ||
|
||
// Load the latest revision. | ||
$entity_type = $node->getEntityType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le'ts keep this the way it was and load the latest revision in theNodeShouldHaveTheFollowingVersion
| major | 1 | | ||
| minor | 0 | | ||
| patch | 0 | | ||
# Set to Published nad back to Draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and
$this->container->get('oe_editorial_entity_version.entity_version_installer')->addEntityVersionFieldToWorkflowBundles('oe_corporate_workflow', $default_value); | ||
/** @var \Drupal\field\Entity\FieldConfig $field_config */ | ||
$field_config = $this->container->get('entity_type.manager')->getStorage('field_config')->load('node.test_node_type.version'); | ||
$this->assertNotEmpty($field_config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert instance of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All works as intended.
Attention! The https://github.com/openeuropa/entity_version/pull/7/files PR has to be merged at first!