Loading modules/paragraphs_library/paragraphs_library.module +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ function paragraphs_library_make_library_item_submit(array $form, FormStateInter // Replacing element in the array. $library_item = LibraryItem::createFromParagraph($submit['widget_state']['paragraphs'][$submit['delta']]['entity']); // If the item has a moderation field, set it to published. if ($library_item->hasField('moderation_state')) { $library_item->set('moderation_state', 'published'); } $library_item->save(); // Replace this paragraph with a library reference one. Loading modules/paragraphs_library/src/Entity/LibraryItem.php +5 −0 Original line number Diff line number Diff line Loading @@ -267,6 +267,11 @@ class LibraryItem extends EditorialContentEntityBase implements LibraryItemInter 'langcode' => $paragraph->language()->getId(), ]); // If the item has a moderation field, set it to published. if ($library_item->hasField('moderation_state')) { $library_item->set('moderation_state', 'published'); } // Build the label in each available translation and ensure the translations // exist. foreach ($duplicate_paragraph->getTranslationLanguages() as $langcode => $language) { Loading modules/paragraphs_library/tests/src/Functional/MultilingualBehaviorTest.php +80 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,86 @@ class MultilingualBehaviorTest extends ParagraphsTestBase { $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); } /** * Tests converting moderated translated nested paragraph into library. */ public function testMoveModeratedTranslatedNestedParagraphToLibrary() { $this->container->get('module_installer')->install(['content_moderation']); $this->createEditorialWorkflow('paragraphed_test'); $this->loginAsAdmin([ 'access administration pages', 'view any unpublished content', 'view all revisions', 'revert all revisions', 'view latest version', 'view any unpublished content', 'use ' . $this->workflow->id() . ' transition create_new_draft', 'use ' . $this->workflow->id() . ' transition publish', 'use ' . $this->workflow->id() . ' transition archived_published', 'use ' . $this->workflow->id() . ' transition archived_draft', 'use ' . $this->workflow->id() . ' transition archive', 'administer nodes', 'bypass node access', 'administer content translation', 'translate any entity', 'create content translations', 'administer languages', 'administer content types', 'administer node form display', 'edit any paragraphed_test content', 'create paragraphed_test content', 'edit behavior plugin settings', 'administer paragraphs library', 'administer workflows' ]); $this->drupalGet('admin/config/workflow/workflows/manage/' . $this->workflow->id() . '/type/paragraphs_library_item'); $edit = [ 'bundles[paragraphs_library_item]' => 1, ]; $this->submitForm($edit, 'Save'); $this->enableConvertingParagraphsTypeToLibrary('nested_paragraph'); // Add node with text paragraph. $this->drupalGet('node/add/paragraphed_test'); $this->submitForm([], 'field_paragraphs_nested_paragraph_add_more'); $this->submitForm([], 'field_paragraphs_0_subform_field_err_field_test_content_add_more'); $edit = [ 'title[0][value]' => 'En label Test node nested', 'field_paragraphs[0][subform][field_err_field][0][subform][field_paragraphs_text][0][value]' => 'En label Example text for test in nested paragraph', 'moderation_state[0][state]' => 'published' ]; $this->submitForm($edit, 'Save'); // Add translation for node. $node = $this->drupalGetNodeByTitle('En label Test node nested'); $this->drupalGet('node/' . $node->id() . '/translations'); $this->clickLink('Add'); $edit = [ 'title[0][value]' => 'Testknoten', 'field_paragraphs[0][subform][field_err_field][0][subform][field_paragraphs_text][0][value]' => 'De label Beispieltext fur den Test in geschachteltem Absatz.', ]; $this->submitForm($edit, 'Save (this translation)'); // Convert translated paragraph to library. $this->drupalGet($node->toUrl('edit-form')); $this->submitForm([], 'field_paragraphs_0_promote_to_library'); $this->submitForm([], 'Save (this translation)'); // Visible to admins. $this->drupalGet($node->toUrl()); $this->assertSession()->pageTextContains('En label Example text for test in nested paragraph'); $this->drupalGet('de/node/' . $node->id()); $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); // And to anonymous users as well. $this->drupalLogout(); $this->drupalGet('de/node/' . $node->id()); $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); } /** * Tests converting translated nested paragraph from library. */ Loading Loading
modules/paragraphs_library/paragraphs_library.module +0 −4 Original line number Diff line number Diff line Loading @@ -112,10 +112,6 @@ function paragraphs_library_make_library_item_submit(array $form, FormStateInter // Replacing element in the array. $library_item = LibraryItem::createFromParagraph($submit['widget_state']['paragraphs'][$submit['delta']]['entity']); // If the item has a moderation field, set it to published. if ($library_item->hasField('moderation_state')) { $library_item->set('moderation_state', 'published'); } $library_item->save(); // Replace this paragraph with a library reference one. Loading
modules/paragraphs_library/src/Entity/LibraryItem.php +5 −0 Original line number Diff line number Diff line Loading @@ -267,6 +267,11 @@ class LibraryItem extends EditorialContentEntityBase implements LibraryItemInter 'langcode' => $paragraph->language()->getId(), ]); // If the item has a moderation field, set it to published. if ($library_item->hasField('moderation_state')) { $library_item->set('moderation_state', 'published'); } // Build the label in each available translation and ensure the translations // exist. foreach ($duplicate_paragraph->getTranslationLanguages() as $langcode => $language) { Loading
modules/paragraphs_library/tests/src/Functional/MultilingualBehaviorTest.php +80 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,86 @@ class MultilingualBehaviorTest extends ParagraphsTestBase { $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); } /** * Tests converting moderated translated nested paragraph into library. */ public function testMoveModeratedTranslatedNestedParagraphToLibrary() { $this->container->get('module_installer')->install(['content_moderation']); $this->createEditorialWorkflow('paragraphed_test'); $this->loginAsAdmin([ 'access administration pages', 'view any unpublished content', 'view all revisions', 'revert all revisions', 'view latest version', 'view any unpublished content', 'use ' . $this->workflow->id() . ' transition create_new_draft', 'use ' . $this->workflow->id() . ' transition publish', 'use ' . $this->workflow->id() . ' transition archived_published', 'use ' . $this->workflow->id() . ' transition archived_draft', 'use ' . $this->workflow->id() . ' transition archive', 'administer nodes', 'bypass node access', 'administer content translation', 'translate any entity', 'create content translations', 'administer languages', 'administer content types', 'administer node form display', 'edit any paragraphed_test content', 'create paragraphed_test content', 'edit behavior plugin settings', 'administer paragraphs library', 'administer workflows' ]); $this->drupalGet('admin/config/workflow/workflows/manage/' . $this->workflow->id() . '/type/paragraphs_library_item'); $edit = [ 'bundles[paragraphs_library_item]' => 1, ]; $this->submitForm($edit, 'Save'); $this->enableConvertingParagraphsTypeToLibrary('nested_paragraph'); // Add node with text paragraph. $this->drupalGet('node/add/paragraphed_test'); $this->submitForm([], 'field_paragraphs_nested_paragraph_add_more'); $this->submitForm([], 'field_paragraphs_0_subform_field_err_field_test_content_add_more'); $edit = [ 'title[0][value]' => 'En label Test node nested', 'field_paragraphs[0][subform][field_err_field][0][subform][field_paragraphs_text][0][value]' => 'En label Example text for test in nested paragraph', 'moderation_state[0][state]' => 'published' ]; $this->submitForm($edit, 'Save'); // Add translation for node. $node = $this->drupalGetNodeByTitle('En label Test node nested'); $this->drupalGet('node/' . $node->id() . '/translations'); $this->clickLink('Add'); $edit = [ 'title[0][value]' => 'Testknoten', 'field_paragraphs[0][subform][field_err_field][0][subform][field_paragraphs_text][0][value]' => 'De label Beispieltext fur den Test in geschachteltem Absatz.', ]; $this->submitForm($edit, 'Save (this translation)'); // Convert translated paragraph to library. $this->drupalGet($node->toUrl('edit-form')); $this->submitForm([], 'field_paragraphs_0_promote_to_library'); $this->submitForm([], 'Save (this translation)'); // Visible to admins. $this->drupalGet($node->toUrl()); $this->assertSession()->pageTextContains('En label Example text for test in nested paragraph'); $this->drupalGet('de/node/' . $node->id()); $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); // And to anonymous users as well. $this->drupalLogout(); $this->drupalGet('de/node/' . $node->id()); $this->assertSession()->pageTextContains('De label Beispieltext fur den Test in geschachteltem Absatz.'); } /** * Tests converting translated nested paragraph from library. */ Loading