function _options_values_in_use

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

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

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. The logic has been moved into \Drupal\options\Hook\OptionsHooks::hasValuesInUse() protected method and no replacement is provided.

See also

https://www.drupal.org/node/3572185

File

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

Code

function _options_values_in_use($entity_type, $field_name, $values) {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. The logic has been moved into \\Drupal\\options\\Hook\\OptionsHooks::hasValuesInUse() protected method and no replacement is provided. See https://www.drupal.org/node/3572185', E_USER_DEPRECATED);
  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.