You are here

public function ParagraphsSetsFunctionalTestTrait::addParagraphRefFieldInNodeType in Paragraphs Sets 8.2

Create a paragraph reference field in a given node bundle.

Parameters

string $paragraphRefFieldName: The machine name for the paragraph reference field.

string $nodeType: The machine name for the node type.

1 call to ParagraphsSetsFunctionalTestTrait::addParagraphRefFieldInNodeType()
ParagraphSetBasicFunctionality::setUp in tests/src/Functional/ParagraphSetBasicFunctionality.php

File

tests/src/Traits/ParagraphsSetsFunctionalTestTrait.php, line 33

Class

ParagraphsSetsFunctionalTestTrait
Contains functions common to functional paragraphs sets tests.

Namespace

Drupal\Tests\paragraphs_sets\Traits

Code

public function addParagraphRefFieldInNodeType(string $paragraphRefFieldName, string $nodeType) {
  $this
    ->addParagraphsField($nodeType, $paragraphRefFieldName, 'node', 'paragraphs');

  /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $formDisplay */
  $formDisplay = \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', $nodeType);
  $displaySettings = $formDisplay
    ->getComponent($paragraphRefFieldName);
  $displaySettings['third_party_settings']['paragraphs_sets']['paragraphs_sets']['use_paragraphs_sets'] = 1;
  $formDisplay
    ->setComponent($paragraphRefFieldName, $displaySettings);
  $formDisplay
    ->save();
}