From 333d9e335963064d2d823cc303addeb05ccb3a86 Mon Sep 17 00:00:00 2001 From: upchuk Date: Fri, 26 Apr 2019 12:02:25 +0200 Subject: [PATCH] Fixing the menu local task alter moderation check. --- .../oe_editorial_corporate_workflow.module | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.module b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.module index 3b516a3..cea0ec4 100644 --- a/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.module +++ b/modules/oe_editorial_corporate_workflow/oe_editorial_corporate_workflow.module @@ -19,6 +19,12 @@ function oe_editorial_corporate_workflow_menu_local_tasks_alter(&$data): void { return; } + /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */ + $moderation_info = \Drupal::service('content_moderation.moderation_information'); + if (!$moderation_info->isModeratedEntity($node)) { + return; + } + // Edit tab. if (!empty($data['tabs'][0]['entity.node.edit_form']['#link'])) { if (_oe_editorial_corporate_workflow_is_last_revision_published($node)) { @@ -38,13 +44,11 @@ function oe_editorial_corporate_workflow_menu_local_tasks_alter(&$data): void { if (!empty($data['tabs'][0]['entity.node.canonical']['#link'])) { /** @var \Drupal\content_moderation\ModerationInformationInterface $moderation_info */ $moderation_info = \Drupal::service('content_moderation.moderation_information'); - if ($moderation_info->isModeratedEntity($node)) { - if ($moderation_info->isDefaultRevisionPublished($node) || $moderation_info->isLiveRevision($node)) { - $data['tabs'][0]['entity.node.canonical']['#link']['title'] = t('View published'); - } - else { - $data['tabs'][0]['entity.node.canonical']['#link']['title'] = t('View draft'); - } + if ($moderation_info->isDefaultRevisionPublished($node) || $moderation_info->isLiveRevision($node)) { + $data['tabs'][0]['entity.node.canonical']['#link']['title'] = t('View published'); + } + else { + $data['tabs'][0]['entity.node.canonical']['#link']['title'] = t('View draft'); } } }