function _options_values_in_use

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

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

2 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.
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.