public EntityTypeInfo::formAlter(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.
See also
File
- core/modules/content_moderation/src/EntityTypeInfo.php, line 348
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderation
Code
public function formAlter(array &$form, FormStateInterface $form_state, $form_id) { $form_object = $form_state->getFormObject(); if ($form_object instanceof BundleEntityFormBase) { $type = $form_object->getEntity()->getEntityType(); if ($this->moderationInfo->canModerateEntitiesOfEntityType($type)) { $this->entityTypeManager->getHandler($type->getBundleOf(), 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id); } } elseif ($form_object instanceof ContentEntityFormInterface) { $entity = $form_object->getEntity(); if ($this->moderationInfo->isModeratedEntity($entity)) { $this->entityTypeManager ->getHandler($entity->getEntityTypeId(), 'moderation') ->enforceRevisionsEntityFormAlter($form, $form_state, $form_id); // Submit handler to redirect to the latest version, if available. $form['actions']['submit']['#submit'][] = [EntityTypeInfo::class, 'bundleFormRedirect']; } } }
Please login to continue.