private function FixturesDataTrait::createFieldWithStorage in Acquia Lift Connector 8.4
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 tests/
src/ Functional/ SettingsTest.php
File
- tests/
src/ Unit/ Traits/ FixturesDataTrait.php, line 76
Class
- FixturesDataTrait
- Fixtures Data Trait.
Namespace
Drupal\Tests\acquia_lift\Unit\TraitsCode
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();
}