You are here

protected function StockLevelFieldCreationTrait::configureFormDisplay in Commerce Stock 8

Set, update and configure the widget for the stock level field.

Parameters

string $widget_id: The id of the widget.

array $widget_settings: A list of widget settings that will be added to the widget defaults.

string $entity_type: The entity type.

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

8 calls to StockLevelFieldCreationTrait::configureFormDisplay()
StockLevelFieldCreationTrait::createStockLevelField in modules/field/tests/src/Kernel/StockLevelFieldCreationTrait.php
Creates a new stock level field.
StockLevelWidgetsTest::testAbsoluteStockLevelWidget in modules/field/tests/src/Functional/StockLevelWidgetsTest.php
Testing the commerce_stock_level_absolute widget.
StockLevelWidgetsTest::testAbsoluteTransactionStockLevelWidgetSingleVariationMode in modules/field/tests/src/Functional/StockLevelWidgetsTest.php
Tests the absolute stock level widget in single variation mode.
StockLevelWidgetsTest::testDeprecatedWidget in modules/field/tests/src/Functional/StockLevelWidgetsTest.php
Test the deprecated simple widget.
StockLevelWidgetsTest::testLinkToTransactionFormWidget in modules/ui/tests/Functional/StockLevelWidgetsTest.php
Testing the commerce_stock_level_transaction_form_link widget.

... See full list

File

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

Class

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

Namespace

Drupal\Tests\commerce_stock_field\Kernel

Code

protected function configureFormDisplay($widget_id, array $widget_settings, $entity_type, $bundle) {
  $entityTypeManager = \Drupal::entityTypeManager();
  $form_display = $entityTypeManager
    ->getStorage('entity_form_display')
    ->load($entity_type . '.' . $bundle . '.default');
  $widget = $form_display
    ->getComponent($this
    ->getFieldname());
  $widget['type'] = $widget_id;
  $widget['settings'] = $widget_settings;
  $form_display
    ->setComponent($this
    ->getFieldname(), $widget)
    ->save();
  $entityTypeManager
    ->getStorage('entity_form_display')
    ->resetCache([
    $form_display
      ->id(),
  ]);
  $entityTypeManager
    ->clearCachedDefinitions();
}