You are here

private function MessageEntityDelete::createTermReferenceField in Message 8

Create a term reference field.

Parameters

bool $multiple: Determine of the field should be multiple.

string $name: The name of the field.

1 call to MessageEntityDelete::createTermReferenceField()
MessageEntityDelete::setUp in tests/src/Functional/MessageEntityDelete.php

File

tests/src/Functional/MessageEntityDelete.php, line 99

Class

MessageEntityDelete
Test the Message delete on entity delete functionality.

Namespace

Drupal\Tests\message\Functional

Code

private function createTermReferenceField($multiple, $name) {

  // Create a term reference field.
  FieldStorageConfig::create([
    'field_name' => $name,
    'entity_type' => 'message',
    'type' => 'entity_reference',
    'cardinality' => $multiple ? FieldStorageConfig::CARDINALITY_UNLIMITED : 1,
    'settings' => [
      'target_type' => 'taxonomy_term',
      'allowed_values' => [
        [
          'vocabulary' => $this->vocabulary
            ->id(),
          'parent' => 0,
        ],
      ],
    ],
  ])
    ->save();
  FieldConfig::create([
    'field_name' => $name,
    'entity_type' => 'message',
    'bundle' => 'dummy_message',
    'required' => TRUE,
  ])
    ->save();
}