NodeModerationHandler::enforceRevisionsBundleFormAlter

public NodeModerationHandler::enforceRevisionsBundleFormAlter(array &$form, FormStateInterface $form_state, $form_id)

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

core/modules/content_moderation/src/Entity/Handler/NodeModerationHandler.php, line 37

Class

NodeModerationHandler
Customizations for node entities.

Namespace

Drupal\content_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('content_moderation', 'enabled', FALSE)) {
    // Force the revision checkbox on.
    $form['workflow']['options']['#default_value']['revision'] = 'revision';
    $form['workflow']['options']['revision']['#disabled'] = TRUE;
  }
}
doc_Drupal
2016-10-29 09:31:00
Comments
Leave a Comment

Please login to continue.