protected function ParagraphsCollapsedSummaryTest::addParagraphsField

Adds a field to a given paragraph type.

Parameters

string $paragraph_type_name: Paragraph type name to be used.

string $field_name: Paragraphs field name to be used.

string $field_type: Type of the field.

array $field_edit: Edit settings for the field.

1 call to ParagraphsCollapsedSummaryTest::addParagraphsField()

File

paragraphs/tests/src/Kernel/ParagraphsCollapsedSummaryTest.php, line 199

Class

ParagraphsCollapsedSummaryTest
Tests the collapsed summary options.

Namespace

Drupal\Tests\paragraphs\Kernel

Code

protected function addParagraphsField($paragraph_type_name, $field_name, $field_type, $field_edit = []) {

  // Add a paragraphs field.
  $field_storage = FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => 'paragraph',
    'type' => $field_type,
    'cardinality' => '-1',
    'settings' => $field_edit,
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => $paragraph_type_name,
    'settings' => [
      'handler' => 'default:paragraph',
      'handler_settings' => [
        'target_bundles' => NULL,
      ],
    ],
  ]);
  $field
    ->save();
}