Same name and namespace in other branches
  1. 8.9.x core/modules/options/options.module \_options_values_in_use()
  2. 9 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
Defines selection, check box and radio button widgets for text and numeric fields.

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;
}