You are here

protected function ParagraphsIsChangedTest::addParagraphsField in Paragraphs 8

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 ParagraphsIsChangedTest::addParagraphsField()
ParagraphsIsChangedTest::setUp in tests/src/Kernel/ParagraphsIsChangedTest.php

File

tests/src/Kernel/ParagraphsIsChangedTest.php, line 81

Class

ParagraphsIsChangedTest
Tests \Drupal\Paragraphs\Entity\Paragraph::isChanged().

Namespace

Drupal\Tests\paragraphs\Kernel

Code

protected function addParagraphsField($paragraph_type_name, $field_name, $field_type, array $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();
}