You are here

protected function StockLevelFieldCreationTrait::attachStockLevelField in Commerce Stock 8

Attaches a stock level field to an entity.

Parameters

Drupal\field\Entity\FieldStorageConfig $field_storage: The field storage.

string $bundle: The bundle this field will be added to.

array $field_settings: A list of field settings that will be added to the defaults.

1 call to StockLevelFieldCreationTrait::attachStockLevelField()
StockLevelFieldCreationTrait::createStockLevelField in modules/field/tests/src/Kernel/StockLevelFieldCreationTrait.php
Creates a new stock level field.

File

modules/field/tests/src/Kernel/StockLevelFieldCreationTrait.php, line 83

Class

StockLevelFieldCreationTrait
Provides methods to attach and configure a stock level field.

Namespace

Drupal\Tests\commerce_stock_field\Kernel

Code

protected function attachStockLevelField(FieldStorageConfig $field_storage, $bundle, array $field_settings) {
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => $bundle,
    'label' => $this
      ->getFieldname(),
    'required' => FALSE,
    'settings' => $field_settings,
  ])
    ->save();
}