You are here

private function FixturesDataTrait::createFieldWithStorage in Acquia Lift Connector 8

Same name and namespace in other branches
  1. 8.3 src/Tests/FixturesDataTrait.php \Drupal\acquia_lift\Tests\FixturesDataTrait::createFieldWithStorage()

Creates a field with storage.

Parameters

string $field_name: The field name.

string $entity_type: The field entity type.

int $bundle: The field's bundle.

array $target_bundles: The field's target bundles.

array $storage_settings: The field storage's settings.

string $storage_type: The field storage's type.

1 call to FixturesDataTrait::createFieldWithStorage()
SettingsTest::setUp in src/Tests/SettingsTest.php
Sets up a Drupal site for running functional and integration tests.

File

src/Tests/FixturesDataTrait.php, line 82
Contains \Drupal\acquia_lift\Tests\FixturesDataTrait.

Class

FixturesDataTrait
Fixtures Data Trait.

Namespace

Drupal\acquia_lift\Tests

Code

private function createFieldWithStorage($field_name, $entity_type, $bundle, $target_bundles, $storage_settings, $storage_type) {
  $field_storage = FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => $entity_type,
    'translatable' => FALSE,
    'settings' => $storage_settings,
    'type' => $storage_type,
    'cardinality' => 1,
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $field_storage,
    'entity_type' => $entity_type,
    'bundle' => $bundle,
    'settings' => [
      'handler' => 'default',
      'handler_settings' => [
        'target_bundles' => $target_bundles,
      ],
    ],
  ]);
  $field
    ->save();
}