You are here

public function NodeModerationHandler::enforceRevisionsBundleFormAlter in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Handler/NodeModerationHandler.php \Drupal\workbench_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter()

Alters bundle forms to enforce revision handling.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

string $form_id: The form id.

Overrides ModerationHandler::enforceRevisionsBundleFormAlter

See also

hook_form_alter()

File

src/Entity/Handler/NodeModerationHandler.php, line 24

Class

NodeModerationHandler
Customizations for node entities.

Namespace

Drupal\workbench_moderation\Entity\Handler

Code

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

  /* @var \Drupal\node\Entity\NodeType $entity */
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  if ($entity
    ->getThirdPartySetting('workbench_moderation', 'enabled', FALSE)) {

    // Force the revision checkbox on.
    $form['workflow']['options']['#default_value']['revision'] = 'revision';
    $form['workflow']['options']['revision']['#disabled'] = TRUE;
  }
}