public function MobileNumberFieldTest::updateFieldConfig in Mobile Number 8
Same name and namespace in other branches
- 2.0.x src/Tests/MobileNumberFieldTest.php \Drupal\mobile_number\Tests\MobileNumberFieldTest::updateFieldConfig()
Update field config setting.
Parameters
string $name: Name of content type.
string $setting: Setting key.
mixed $value: Value.
1 call to MobileNumberFieldTest::updateFieldConfig()
- MobileNumberFieldTest::testNumberValidity in src/
Tests/ MobileNumberFieldTest.php - Test number validation.
File
- src/
Tests/ MobileNumberFieldTest.php, line 395
Class
- MobileNumberFieldTest
- Mobile number field functionality.'.
Namespace
Drupal\mobile_number\TestsCode
public function updateFieldConfig($name, $setting, $value) {
/** @var \Drupal\field\FieldConfigInterface $field */
$fields = \Drupal::service('entity_type.manager')
->getStorage('field_config')
->loadByProperties([
'field_name' => "field_{$name}",
]);
$field = reset($fields);
$new_field = FieldConfig::create($field
->toArray());
$new_field->original = $field;
$new_field
->setSetting($setting, $value);
$new_field
->enforceIsNew(FALSE);
$new_field
->save();
}