Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

protected function ParagraphsIsChangedTest::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 ParagraphsIsChangedTest::addParagraphsField()

File

paragraphs/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();
}