Update a content type field's allowed values programmatically I have a list field in the content type and in the config table , the field storage details saved as follows : 

collection:
name: field.storage.node.field_ip_range_sec_zone
data: a:17:{s:4:"uuid";s:36:"9d20e561-e39c-4c11-b100-ff3a29a75267";s:8:"langcode";
                                            s:2:"en";s:6:"status";b:1;s:12:"dependencies";a:1:{s:6:"module";a:3{i:0;s:17:
                                        "field_permissions";i:1;s:4:"node";i:2;s:7:"options";}}s:20:"third_party_settings";
                                    a:1:{s:17:"field_permissions";a:1:{s:15:"permission_type";s:6:"public";}}s:2:"id";
                                s:28:"node.field_ip_range_sec_zone";s:10:"field_name";s:23:"field_ip_range_sec_zone";
                            s:11:"entity_type";s:4:"node";s:4:"type";s:11:"list_string";s:8:"settings";a:2:
                        {s:14:"allowed_values";a:3:{i:0;a:2:{s:5:"value";s:2:"E1";s:5:"label";s:2:"E1";}
                i:1;a:2{s:5:"value";s:2:"C2";s:5:"label";s:2:"C2";}i:2;a:2{s:5:"value";s:2:"D1";s:5:"label";s:2:"D1";}}
            s:23:"allowed_values_function";s:0:"";}s:6:"module";s:7:"options";s:6:"locked";b:0;s:11:
        "cardinality";i:1;s:12:"translatable";b:1;s:7:"indexes";a:0:{}s:22:"persist_with_no_fields";
    b:0;s:14:"custom_storage";b:0;}


As you can see there is Allowed values (E1,C2,D1) , and now i want to add an additional value to the allowed values , How can i do that ?

WHAT I HAVE TRIED



I could get the allowed values using the following : 

$entity_type = 'node';
$bundle = 'ip_range';
$field_name = 'field_ip_range_sec_zone';
$ip_sec_zone_storage_values = \Drupal\field\Entity\FieldStorageConfig::loadByName($entity_type, $field_name);


But dont know how to update it , Any idea ??
Those are settings, you get them using $ip_sec_zone_storage_values-&gt;getSetting('allowed_values'),, in there you'll find those settings, you can add another one, set the settings back with setSetting('allowed_values', $allowed_values) and then ->save() to save the field storage config:

$allowed_values = $ip_sec_zone_storage_values-&gt;getSetting('allowed_values');
// The new value.
$allowed_values[$ipseczone] = $ipseczone;
$ip_sec_zone_storage_values-&gt;setSetting('allowed_values', $allowed_values);
$ip_sec_zone_storage_values-&gt;save();