You are here

protected function ParagraphsTestBase::setAddMode in Paragraphs 8

Same name in this branch
  1. 8 tests/src/Functional/WidgetLegacy/ParagraphsTestBase.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsTestBase::setAddMode()
  2. 8 tests/src/Functional/WidgetStable/ParagraphsTestBase.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsTestBase::setAddMode()

Sets the Paragraphs widget add mode.

Parameters

string $content_type: Content type name where to set the widget mode.

string $paragraphs_field: Paragraphs field to change the mode.

string $mode: Mode to be set. ('dropdown', 'select' or 'button').

2 calls to ParagraphsTestBase::setAddMode()
ParagraphsAddModesTest::testDropDownMode in tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php
Tests the add drop down button.
ParagraphsAddModesTest::testSelectMode in tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php
Tests the add select mode.
1 method overrides ParagraphsTestBase::setAddMode()
ParagraphsTestBase::setAddMode in tests/src/Functional/WidgetStable/ParagraphsTestBase.php
Sets the Paragraphs widget add mode.

File

tests/src/Functional/WidgetLegacy/ParagraphsTestBase.php, line 109

Class

ParagraphsTestBase
Base class for tests.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

protected function setAddMode($content_type, $paragraphs_field, $mode) {
  $form_display = EntityFormDisplay::load('node.' . $content_type . '.default')
    ->setComponent($paragraphs_field, [
    'type' => 'entity_reference_paragraphs',
    'settings' => [
      'add_mode' => $mode,
    ],
  ]);
  $form_display
    ->save();
}