Loading core/modules/content_moderation/src/EntityTypeInfo.php +21 −22 Original line number Diff line number Diff line Loading @@ -321,19 +321,19 @@ public function entityPrepareForm(EntityInterface $entity, $operation, FormState public function formAlter(array &$form, FormStateInterface $form_state, $form_id) { $form_object = $form_state->getFormObject(); if ($form_object instanceof BundleEntityFormBase) { $config_entity_type = $form_object->getEntity()->getEntityType(); $bundle_of = $config_entity_type->getBundleOf(); $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->canModerateEntitiesOfEntityType($bundle_of_entity_type)) { $this->entityTypeManager->getHandler($config_entity_type->getBundleOf(), 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id); && $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(); if ($this->moderationInfo->isModeratedEntity($entity)) { $this->entityTypeManager ->getHandler($entity->getEntityTypeId(), 'moderation') ->enforceRevisionsEntityFormAlter($form, $form_state, $form_id); Loading @@ -354,7 +354,6 @@ public function formAlter(array &$form, FormStateInterface $form_state, $form_id } } } } /** * Checks whether the specified form allows to edit a moderated entity. Loading core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -67,9 +67,18 @@ public function testEnablingOnExistingContent() { ], t('Save')); $this->assertText('Not moderated Test has been created.'); // Check that the 'Create new revision' is not disabled. $this->drupalGet('/admin/structure/types/manage/not_moderated'); $this->assertNull($this->assertSession()->fieldExists('options[revision]')->getAttribute('disabled')); // Now enable moderation state. $this->enableModerationThroughUi('not_moderated'); // Check that the 'Create new revision' checkbox is checked and disabled. $this->drupalGet('/admin/structure/types/manage/not_moderated'); $this->assertSession()->checkboxChecked('options[revision]'); $this->assertSession()->fieldDisabled('options[revision]'); // And make sure it works. $nodes = \Drupal::entityTypeManager()->getStorage('node') ->loadByProperties(['title' => 'Test']); Loading core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id, $this->drupalGet('admin/structure/types'); $this->clickLink('Add content type'); // Check that the 'Create new revision' checkbox is checked and disabled. $this->assertSession()->checkboxChecked('options[revision]'); $this->assertSession()->fieldDisabled('options[revision]'); $edit = [ 'name' => $content_type_name, 'type' => $content_type_id, Loading Loading
core/modules/content_moderation/src/EntityTypeInfo.php +21 −22 Original line number Diff line number Diff line Loading @@ -321,19 +321,19 @@ public function entityPrepareForm(EntityInterface $entity, $operation, FormState public function formAlter(array &$form, FormStateInterface $form_state, $form_id) { $form_object = $form_state->getFormObject(); if ($form_object instanceof BundleEntityFormBase) { $config_entity_type = $form_object->getEntity()->getEntityType(); $bundle_of = $config_entity_type->getBundleOf(); $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->canModerateEntitiesOfEntityType($bundle_of_entity_type)) { $this->entityTypeManager->getHandler($config_entity_type->getBundleOf(), 'moderation')->enforceRevisionsBundleFormAlter($form, $form_state, $form_id); && $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(); if ($this->moderationInfo->isModeratedEntity($entity)) { $this->entityTypeManager ->getHandler($entity->getEntityTypeId(), 'moderation') ->enforceRevisionsEntityFormAlter($form, $form_state, $form_id); Loading @@ -354,7 +354,6 @@ public function formAlter(array &$form, FormStateInterface $form_state, $form_id } } } } /** * Checks whether the specified form allows to edit a moderated entity. Loading
core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTypeTest.php +9 −0 Original line number Diff line number Diff line Loading @@ -67,9 +67,18 @@ public function testEnablingOnExistingContent() { ], t('Save')); $this->assertText('Not moderated Test has been created.'); // Check that the 'Create new revision' is not disabled. $this->drupalGet('/admin/structure/types/manage/not_moderated'); $this->assertNull($this->assertSession()->fieldExists('options[revision]')->getAttribute('disabled')); // Now enable moderation state. $this->enableModerationThroughUi('not_moderated'); // Check that the 'Create new revision' checkbox is checked and disabled. $this->drupalGet('/admin/structure/types/manage/not_moderated'); $this->assertSession()->checkboxChecked('options[revision]'); $this->assertSession()->fieldDisabled('options[revision]'); // And make sure it works. $nodes = \Drupal::entityTypeManager()->getStorage('node') ->loadByProperties(['title' => 'Test']); Loading
core/modules/content_moderation/tests/src/Functional/ModerationStateTestBase.php +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ protected function createContentTypeFromUi($content_type_name, $content_type_id, $this->drupalGet('admin/structure/types'); $this->clickLink('Add content type'); // Check that the 'Create new revision' checkbox is checked and disabled. $this->assertSession()->checkboxChecked('options[revision]'); $this->assertSession()->fieldDisabled('options[revision]'); $edit = [ 'name' => $content_type_name, 'type' => $content_type_id, Loading