Problem/Motivation

Users are using workbench moderation module for managing their publication workflows.
They need to configure which statuses should trigger the upload to Lingotek, and which transitions need to happen just after content translations have been downloaded.

Proposed resolution

In Lingotek content settings, we should be able of configure for each content entity bundle which status of the workbench_moderation workflow needs to trigger the upload. Only in that status, we will upload content if the profile is set up as automatic upload.

Remaining tasks

When content is saved with workbench moderation enabled, but not in the status which we configured for upload, we should prevent the upload.
When content translation is downloaded with workbench moderation enabled, if the status is the source status of the configured transition, execute the transition.
Implements tests for each scenario.

User interface changes

Lingotek content settings will have a new column for configuring the status that triggers the upload and the workbench moderation transition that needs to be executed.

API changes

API additions:
TBD

Data model changes

Settings include workbench moderation settings per bundle.
TBD

CommentFileSizeAuthor
#37 2901235-workbench-moderation-integration-36.patch74.1 KBpenyaskito
#37 2901235-workbench-moderation-integration.35-36.interdiff.txt1.12 KBpenyaskito
#35 2901235-workbench-moderation-integration-35.patch73.76 KBpenyaskito
#35 2901235-workbench-moderation-integration.33-35.interdiff.txt581 bytespenyaskito
#33 2901235-workbench-moderation-integration-33.patch73.76 KBpenyaskito
#33 2901235-workbench-moderation-integration.32-33.interdiff.txt23.19 KBpenyaskito
#32 2901235-workbench-moderation-integration-32.patch72.83 KBpenyaskito
#32 2901235-workbench-moderation-integration.30-32.interdiff.txt915 bytespenyaskito
#30 2901235-workbench-moderation-integration-30.patch72.84 KBpenyaskito
#30 2901235-workbench-moderation-integration.29-30.interdiff.txt11.35 KBpenyaskito
#29 2901235-workbench-moderation-integration-29.patch72.63 KBpenyaskito
#29 2901235-workbench-moderation-integration.27-29.interdiff.txt5.6 KBpenyaskito
#27 2901235-workbench-moderation-integration-27.patch72.26 KBpenyaskito
#27 2901235-workbench-moderation-integration.26-27.interdiff.txt18.29 KBpenyaskito
#26 2901235-workbench-moderation-integration-26.patch65.08 KBpenyaskito
#26 2901235-workbench-moderation-integration.24-26.interdiff.txt13.89 KBpenyaskito
#24 2901235-workbench-moderation-integration-24.patch60.77 KBpenyaskito
#24 2901235-workbench-moderation-integration.22-24.interdiff.txt9.89 KBpenyaskito
#22 2901235-workbench-moderation-integration-22.patch58.82 KBpenyaskito
#22 2901235-workbench-moderation-integration.21-22.interdiff.txt40.27 KBpenyaskito
#21 2901235-workbench-moderation-integration-21.patch45.1 KBpenyaskito
#21 2901235-workbench-moderation-integration.19-21.interdiff.txt2.25 KBpenyaskito
#19 2901235-workbench-moderation-integration-19.patch45.13 KBpenyaskito
#19 2901235-workbench-moderation-integration.17-19.interdiff.txt2.37 KBpenyaskito
#17 2901235-workbench-moderation-integration-17.patch45.48 KBpenyaskito
#17 2901235-workbench-moderation-integration.15-17.interdiff.txt10.94 KBpenyaskito
#15 2901235-workbench-moderation-integration-15.patch42.19 KBpenyaskito
#15 2901235-workbench-moderation-integration.14-15.interdiff.txt15.05 KBpenyaskito
#14 2901235-workbench-moderation-integration-15.patch41.31 KBpenyaskito
#14 2901235-workbench-moderation-integration.13-15.interdiff.txt5.67 KBpenyaskito
#2 2901235-workbench-moderation-integration-2.patch27.7 KBpenyaskito
#4 2901235-workbench-moderation-integration-4.patch27.42 KBpenyaskito
#6 2901235-workbench-moderation-integration-6.patch29.78 KBpenyaskito
#6 2901235-workbench-moderation-integration.interdiff.4-6.txt4.74 KBpenyaskito
#11 2901235-workbench-moderation-integration.6-11.interdiff.txt13.34 KBpenyaskito
#11 2901235-workbench-moderation-integration-11.patch36.39 KBpenyaskito
#13 2901235-workbench-moderation-integration.11-13.interdiff.txt3.66 KBpenyaskito
#13 2901235-workbench-moderation-integration-13.patch36.34 KBpenyaskito
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

penyaskito created an issue. See original summary.

penyaskito’s picture

Worked on form settings and storing per bundle.
Defaults in settings are a published status and the first transition from that status to another published status if it exists.

When content is created or updated, we check the workbench moderation settings for uploading if the profile is set as automatic.

Implemented tests
LingotekWorkbenchModerationTest:

  • testCreateEntityWithAutomaticProfileAndInUploadState
  • testCreateEntityWithAutomaticProfileButNotInUploadState
  • testCreateEntityWithManualProfileAndInUploadState
  • testCreateEntityWithManualProfileButNotInUploadState
  • testModerationToNonUploadStateWithAutomaticProfileDoesntTriggerUpload
  • testModerationToNonUploadStateWithManualProfileDoesntTriggerUpload
  • testModerationToUploadStateWithAutomaticProfileTriggersUpload
  • testModerationToUploadStateWithManualProfileDoesntTriggerUpload
  • testUpdateEntityWithAutomaticProfileAndInUploadState
  • testUpdateEntityWithAutomaticProfileButNotInUploadState
  • testUpdateEntityWithManualProfileAndInUploadState
  • testUpdateEntityWithManualProfileButNotInUploadState

\Drupal\lingotek\Tests\LingotekWorkbenchModerationSettingsTest::testWorkbenchModerationSettings

Status: Needs review » Needs work

The last submitted patch, 2: 2901235-workbench-moderation-integration-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
FileSize
27.42 KB

Tests failed because of the test dependency on workbench_moderation. Created and fixed #2901247: Workbench moderation integration: add workbench_moderation to test dependencies.
Rebased patch.

Status: Needs review » Needs work

The last submitted patch, 4: 2901235-workbench-moderation-integration-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Forgot to include the submit handler in settings form in the patch.
Added phpdoc to LingotekWorkbenchModerationConfigurationService.

Status: Needs review » Needs work

The last submitted patch, 6: 2901235-workbench-moderation-integration-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review

We require the dev version of workbench_moderation for the tests, the moderation form doesn't exist in a tagged version.

Status: Needs review » Needs work

The last submitted patch, 6: 2901235-workbench-moderation-integration-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review

Re-tested after commiting composer.json that ensures last dev is available.
#2901342: Update composer.json

penyaskito’s picture

Only show settings if the bundle is setup as moderatable.
If not, show a text and link to configure moderation.
If the entity does not support moderation, don't show the column.
Tests covering all those cases.

Status: Needs review » Needs work

The last submitted patch, 11: 2901235-workbench-moderation-integration-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Fixed code standards and solved test failures (workbench moderation needed to be setup before lingotek)

penyaskito’s picture

Added handling of the download, with the transition happening (if the source didn't change meanwhile).
Added test for the transition happening on download, when the source status didn't change.
Added test for the transition not happening on download, when the source status changed.

penyaskito’s picture

Extract an interface from \Drupal\lingotek\Moderation\LingotekWorkbenchModerationConfigurationService and created Drupal\lingotek\Moderation namespace.

Status: Needs review » Needs work

The last submitted patch, 15: 2901235-workbench-moderation-integration-15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Created another service as workbench moderation handler, for removing as much as possible from the \Drupal\lingotek\LingotekContentTranslationService class and the lingotek.module file.

Status: Needs review » Needs work

The last submitted patch, 17: 2901235-workbench-moderation-integration-17.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Fixed services definition and fixed phpdoc packages.

Status: Needs review » Needs work

The last submitted patch, 19: 2901235-workbench-moderation-integration-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Fixing references to service.

penyaskito’s picture

Created a factory for abstracting the different strategies for content moderation. It works with tagged services for allowing extensibility.
Implemented a noop content moderation strategy for when there is no content moderation module enabled, as it makes easy to remove any dependencies.
Let's see if this magic works.

Status: Needs review » Needs work

The last submitted patch, 22: 2901235-workbench-moderation-integration-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Fixing test failures and code standards.

penyaskito’s picture

Status: Needs review » Needs work
  1. +++ b/lingotek.module
    @@ -123,6 +123,15 @@ function lingotek_entity_insert(EntityInterface $entity) {
    +      // If workbench moderation is enabled, we need to prevent that content is
    +      // processed if not the right state.
    +      /** @var \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler $moderation_handler */
    +      $moderation_handler = \Drupal::service('lingotek.workbench_moderation_handler');
    
    @@ -237,6 +246,15 @@ function lingotek_entity_update(EntityInterface $entity) {
    +      // If workbench moderation is enabled, we need to prevent that content is
    +      // processed if not the right state.
    +      /** @var \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler $moderation_handler */
    +      $moderation_handler = \Drupal::service('lingotek.workbench_moderation_handler');
    
    +++ b/src/LingotekContentTranslationService.php
    @@ -1050,6 +1050,11 @@ class LingotekContentTranslationService implements LingotekContentTranslationSer
    +      if (\Drupal::moduleHandler()->moduleExists('workbench_moderation')) {
    +        /** @var \Drupal\lingotek\Moderation\LingotekWorkbenchModerationHandler $moderation_handler */
    +        $moderation_handler = \Drupal::service('lingotek.workbench_moderation_handler');
    +        $moderation_handler->performModerationTransitionIfNeeded($entity);
    +      }
    

    Nope, should use the factory instead.

  2. +++ b/src/Moderation/LingotekModerationFactory.php
    @@ -0,0 +1,71 @@
    +class LingotekModerationFactory {
    

    phpdocs missing

  3. +++ b/src/Moderation/LingotekWorkbenchModerationSettingsForm.php
    @@ -0,0 +1,167 @@
    +    return (\Drupal::moduleHandler()->moduleExists('workbench_moderation') &&
    +      (\Drupal::service('workbench_moderation.moderation_information') !== NULL &&
    +        \Drupal::service('workbench_moderation.moderation_information')
    +          ->isModeratableEntityType($entity_type_definition)));
    ...
    +      $published_statuses = \Drupal::entityQuery('moderation_state')->condition('published', TRUE)->execute();
    ...
    +      $transitions = \Drupal::entityQuery('moderation_state_transition')
    ...
    +    /** @var $moderation_info \Drupal\workbench_moderation\ModerationInformationInterface */
    +    $moderation_info = \Drupal::service('workbench_moderation.moderation_information');
    

    inject services.

penyaskito’s picture

Added factory interface. Cleaned up factory.
Removed references to workbench moderation where there shouldn't be.
Added phpdocs.

Missing still test for the factory and injecting services in some places.

penyaskito’s picture

Status: Needs review » Needs work

The last submitted patch, 27: 2901235-workbench-moderation-integration-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

We cannot inject the workbench_moderation services through the services.yml file, as they may not exist.
Instead let's inject the container and get it in the constructor.

penyaskito’s picture

+++ b/src/Moderation/LingotekModerationSettingsFormInterface.php
@@ -0,0 +1,107 @@
+  public function getWorkbenchModerationUploadStatuses($entity_type_id, $bundle);
...
+  public function getDefaultWorkbenchModerationUploadStatus($entity_type_id, $bundle);
...
+  public function getWorkbenchModerationDownloadTransitions($entity_type_id, $bundle);
...
+  public function getDefaultWorkbenchModerationDownloadTransition($entity_type_id, $bundle);

This and its implementations shouldn't contain Workbench.

Replaced $entity_id with $entity_type_id and $bundle_id with $bundle for consistency.

Added missing phpdocs.

Status: Needs review » Needs work

The last submitted patch, 30: 2901235-workbench-moderation-integration-30.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Oops, missed one reference.

penyaskito’s picture

Added check on form submit handler.
Fixing coding standards.

Status: Needs review » Needs work

The last submitted patch, 33: 2901235-workbench-moderation-integration-33.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs review » Needs work

The last submitted patch, 35: 2901235-workbench-moderation-integration-35.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Include the from and to states on the transitions, as there may be more than one with same name.

  • penyaskito committed 4586e89 on 8.x-2.x
    Issue #2901235 by penyaskito: Workbench moderation integration
    
penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Tests passed as expected. McCann reviewed and suggested the last change in the transition labels.

penyaskito’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4586e89 and pushed to 8.x-2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.