enforceRevisionsBundleFormAlter example


  public function formAlter(array &$form, FormStateInterface $form_state$form_id) {
    $form_object = $form_state->getFormObject();
    if ($form_object instanceof BundleEntityFormBase) {
      $config_entity = $form_object->getEntity();
      $bundle_of = $config_entity->getEntityType()->getBundleOf();
      if ($bundle_of
          && ($bundle_of_entity_type = $this->entityTypeManager->getDefinition($bundle_of))
          && $this->moderationInfo->shouldModerateEntitiesOfBundle($bundle_of_entity_type$config_entity->id())) {
        $this->entityTypeManager->getHandler($bundle_of, 'moderation')->enforceRevisionsBundleFormAlter($form$form_state$form_id);
      }
    }
    elseif ($this->isModeratedEntityEditForm($form_object)) {
      /** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
      /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
      $entity = $form_object->getEntity();

      $this->entityTypeManager
        ->getHandler($entity->getEntityTypeId(), 'moderation')
        ->enforceRevisionsEntityFormAlter($form$form_state$form_id);

      
Home | Imprint | This part of the site doesn't use cookies.