Skip to content
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

Merged
merged 13 commits into from
Jul 2, 2019

Conversation

nagyad
Copy link
Member

@nagyad nagyad commented Jun 26, 2019

Attention! The https://github.com/openeuropa/entity_version/pull/7/files PR has to be merged at first!

@nagyad nagyad changed the title Openeuropa 1915 OPENEUROPA-1915: Integrate entity_versions module in oe_editorial Jun 26, 2019
@@ -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'));
Copy link
Contributor

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.
Copy link
Contributor

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;
Copy link
Contributor

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);
}

/**
Copy link
Contributor

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);
Copy link
Contributor

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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translatable.

$node = reset($nodes);

// Load the latest revision.
$entity_type = $node->getEntityType();
Copy link
Contributor

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.
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert instance of

upchuk
upchuk previously approved these changes Jun 28, 2019
Copy link
Member

@imanoleguskiza imanoleguskiza left a 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.

@nagyad nagyad merged commit 9b4bb94 into master Jul 2, 2019
@nagyad nagyad deleted the OPENEUROPA-1915 branch July 2, 2019 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants