Skip to content

Commit

Permalink
Fixing the menu local task alter moderation check.
Browse files Browse the repository at this point in the history
  • Loading branch information
upchuk committed Apr 26, 2019
1 parent 11538a5 commit 333d9e3
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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');
}
}
}
Expand Down

0 comments on commit 333d9e3

Please sign in to comment.