function _options_values_in_use

Same name in other branches
  1. 9 core/modules/options/options.module \_options_values_in_use()
  2. 10 core/modules/options/options.module \_options_values_in_use()
  3. 11.x core/modules/options/options.module \_options_values_in_use()

Checks if a list of values are being used in actual field values.

3 calls to _options_values_in_use()
hook_field_storage_config_update_forbid in core/modules/field/field.api.php
Forbid a field storage update from occurring.
ListItemBase::validateAllowedValues in core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
#element_validate callback for options field allowed values.
options_field_storage_config_update_forbid in core/modules/options/options.module
Implements hook_field_storage_config_update_forbid().

File

core/modules/options/options.module, line 124

Code

function _options_values_in_use($entity_type, $field_name, $values) {
    if ($values) {
        $result = \Drupal::entityQuery($entity_type)->condition($field_name . '.value', $values, 'IN')
            ->count()
            ->accessCheck(FALSE)
            ->range(0, 1)
            ->execute();
        if ($result) {
            return TRUE;
        }
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.