You are here

public function ThunderNodeForm::formAlter in Thunder 8.3

Same name and namespace in other branches
  1. 8.5 modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()
  2. 8.2 modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()
  3. 8.4 modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()
  4. 6.2.x modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()
  5. 6.0.x modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()
  6. 6.1.x modules/thunder_article/src/Form/ThunderNodeForm.php \Drupal\thunder_article\Form\ThunderNodeForm::formAlter()

File

modules/thunder_article/src/Form/ThunderNodeForm.php, line 109

Class

ThunderNodeForm
Base for handler for node add/edit forms.

Namespace

Drupal\thunder_article\Form

Code

public function formAlter(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
  $form_object = $form_state
    ->getFormObject();

  /** @var \Drupal\node\NodeInterface $entity */
  $entity = $form_object
    ->getEntity();
  $storage = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId());
  $latest_revision_id = $storage
    ->getLatestTranslationAffectedRevisionId($entity
    ->id(), $entity
    ->language()
    ->getId());
  if ($latest_revision_id !== NULL && $this->moderationInfo && $this->moderationInfo
    ->hasPendingRevision($entity)) {
    $this->messenger
      ->addWarning($this
      ->t('This %entity_type has unpublished changes from user %user.', [
      '%entity_type' => $entity
        ->get('type')->entity
        ->label(),
      '%user' => $entity
        ->getRevisionUser()
        ->label(),
    ]));
  }
  $form['actions'] = array_merge($form['actions'], $this
    ->actions($entity));
  return $form;
}