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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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.