getTargetEntityTypeId(), $definition->getName()]; if ($entity) { $cache_keys[] = 'entity'; } $cache_id = implode(':', $cache_keys); if (!isset($allowed_values[$cache_id])) { $function = $definition->getSetting('allowed_values_function'); // If $cacheable is FALSE, then the allowed values are not statically // cached. See OptionsAllowedValues::dynamicValues() for an example of // generating dynamic and uncached values. $cacheable = TRUE; if (!empty($function)) { $values = $function($definition, $entity, $cacheable); } else { $values = $definition->getSetting('allowed_values'); } if ($cacheable) { $allowed_values[$cache_id] = $values; } else { return $values; } } return $allowed_values[$cache_id]; } /** * Checks if a list of values are being used in actual field values. */ 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; }