public function ContentEntitySourcePluginUi::reviewForm

Form callback for the job item review form.

Overrides SourcePluginUiBase::reviewForm

File

sources/content/src/ContentEntitySourcePluginUi.php, line 550

Class

ContentEntitySourcePluginUi
Content entity source plugin UI.

Namespace

Drupal\tmgmt_content

Code

public function reviewForm(array $form, FormStateInterface $form_state, JobItemInterface $item) {
  $form = parent::reviewForm($form, $form_state, $item);

  // Only proceed to display the content moderation form if the job item is
  // either active or reviewable.
  if (!$item
    ->isNeedsReview() && !$item
    ->isActive()) {
    return $form;
  }

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = ContentEntitySource::load($item
    ->getItemType(), $item
    ->getItemId());
  if (!$form_state
    ->isRebuilding() && $entity) {

    // In case the original entity is moderated, allow users to update the
    // content moderation state of the translation.
    if (ContentEntitySource::isModeratedEntity($entity)) {
      $form['moderation_state'] = $this
        ->buildContentModerationElement($item, $entity);
    }
    elseif ($entity instanceof EntityPublishedInterface) {
      $form['status'] = $this
        ->buildPublishStateElement($item, $entity);
    }
  }
  return $form;
}