Verified Commit 031d03b6 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2893778 by timmillwood, Sam152, Wim Leers: Remove deprecated Workflows methods

(cherry picked from commit a16b9c74)
parent 9c443f80
Loading
Loading
Loading
Loading
+1 −1
Changes for core/modules/content_moderation/src/EntityOperations.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public function entityPresave(EntityInterface $entity) {
    if ($entity->moderation_state->value) {
      $workflow = $this->moderationInfo->getWorkflowForEntity($entity);
      /** @var \Drupal\content_moderation\ContentModerationState $current_state */
      $current_state = $workflow->getState($entity->moderation_state->value);
      $current_state = $workflow->getTypePlugin()->getState($entity->moderation_state->value);

      // This entity is default if it is new, a new translation, the default
      // revision, or the default revision is not published.
+1 −1
Changes for core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) {
              ->read($unprocessed_configuration);
            $diff = array_diff_key($workflow_config['type_settings']['states'], $original_workflow_config['type_settings']['states']);
            foreach (array_keys($diff) as $state_id) {
              $state = $workflow->getState($state_id);
              $state = $workflow->getTypePlugin()->getState($state_id);
              if ($workflow->getTypePlugin()->workflowStateHasData($workflow, $state)) {
                $event->getConfigImporter()->logError($this->t('The moderation state @state_label is being used, but is not in the source storage.', ['@state_label' => $state->label()]));
              }
+2 −2
Changes for core/modules/content_moderation/src/Form/EntityModerationForm.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ContentEn
      $form['current'] = [
        '#type' => 'item',
        '#title' => $this->t('Status'),
        '#markup' => $workflow->getState($current_state)->label(),
        '#markup' => $workflow->getTypePlugin()->getState($current_state)->label(),
      ];
    }

@@ -137,7 +137,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {

    drupal_set_message($this->t('The moderation state has been updated.'));

    $new_state = $this->moderationInfo->getWorkflowForEntity($entity)->getState($new_state);
    $new_state = $this->moderationInfo->getWorkflowForEntity($entity)->getTypePlugin()->getState($new_state);
    // The page we're on likely won't be visible if we just set the entity to
    // the default state, as we hide that latest-revision tab if there is no
    // forward revision. Redirect to the canonical URL instead, since that will
+3 −3
Changes for core/modules/content_moderation/src/ModerationInformation.php: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public function isLiveRevision(ContentEntityInterface $entity) {
    return $this->isLatestRevision($entity)
      && $entity->isDefaultRevision()
      && $entity->moderation_state->value
      && $workflow->getState($entity->moderation_state->value)->isPublishedState();
      && $workflow->getTypePlugin()->getState($entity->moderation_state->value)->isPublishedState();
  }

  /**
@@ -171,13 +171,13 @@ public function isDefaultRevisionPublished(ContentEntityInterface $entity) {
        // Load the translated revision.
        $language_revision = $default_revision->getTranslation($language->getId());
        // Return TRUE if a translation with a published state is found.
        if ($workflow->getState($language_revision->moderation_state->value)->isPublishedState()) {
        if ($workflow->getTypePlugin()->getState($language_revision->moderation_state->value)->isPublishedState()) {
          return TRUE;
        }
      }
    }

    return $workflow->getState($default_revision->moderation_state->value)->isPublishedState();
    return $workflow->getTypePlugin()->getState($default_revision->moderation_state->value)->isPublishedState();
  }

  /**
+1 −1
Changes for core/modules/content_moderation/src/Permissions.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ public function transitionPermissions() {
    $permissions = [];
    /** @var \Drupal\workflows\WorkflowInterface $workflow */
    foreach (Workflow::loadMultipleByType('content_moderation') as $id => $workflow) {
      foreach ($workflow->getTransitions() as $transition) {
      foreach ($workflow->getTypePlugin()->getTransitions() as $transition) {
        $permissions['use ' . $workflow->id() . ' transition ' . $transition->id()] = [
          'title' => $this->t('Use %transition transition from %workflow workflow.', [
            '%transition' => $transition->label(),
Loading