You are here

public function FileFieldTestBase::updateFileField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::updateFileField()
  2. 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::updateFileField()

Updates an existing file field with new settings.

File

core/modules/file/tests/src/Functional/FileFieldTestBase.php, line 86

Class

FileFieldTestBase
Provides methods specifically for testing File module's field handling.

Namespace

Drupal\Tests\file\Functional

Code

public function updateFileField($name, $type_name, $field_settings = [], $widget_settings = []) {
  $field = FieldConfig::loadByName('node', $type_name, $name);
  $field
    ->setSettings(array_merge($field
    ->getSettings(), $field_settings));
  $field
    ->save();
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', $type_name)
    ->setComponent($name, [
    'settings' => $widget_settings,
  ])
    ->save();
}