diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index 121407e..94373bc 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -322,6 +322,120 @@ function field_info_instance($entity_type, $field_name, $bundle_name) { } /** + * Reads a single field record directly from the database. + * + * Generally, you should use the field_info_field() instead. + * + * This function will not return deleted fields. Use field_read_fields() instead + * for this purpose. + * + * @param $entity_type + * The entity type. + * @param $field_name + * The field name to read. + * @param array $include_additional + * Additional properties to match. + * + * @return + * A field definition array, or FALSE. + * + * @deprecated as of Drupal 8.0. Use + * entity_load('field_entity', 'field_name'). + */ +function field_read_field($entity_type, $field_name, $include_additional = array()) { + $fields = field_read_fields(array('entity_type' => $entity_type, 'name' => $field_name), $include_additional); + return $fields ? current($fields) : FALSE; +} + +/** + * Reads in fields that match an array of conditions. + * + * @param array $conditions + * An array of conditions to match against. Keys are names of properties + * found in field configuration files, and values are conditions to match. + * @param array $include_additional + * The default behavior of this function is to not return fields that have + * been deleted. Setting $include_additional['include_deleted'] to TRUE will + * override this behavior. + * + * @return + * An array of fields matching $params. If + * $include_additional['include_deleted'] is TRUE, the array is keyed by + * field ID, otherwise it is keyed by field name. + * + * @deprecated as of Drupal 8.0. Use + * entity_load_multiple_by_properties('field_entity', $conditions). + */ +function field_read_fields($conditions = array(), $include_additional = array()) { + // Include deleted fields if specified either in the $include_additional or + // the $conditions parameters. + $include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']) || (isset($conditions['deleted']) && $conditions['deleted']); + + // Pass include_deleted to the $conditions array. + $conditions['include_deleted'] = $include_deleted; + + return entity_load_multiple_by_properties('field_entity', $conditions); +} + +/** + * Reads a single instance record from the database. + * + * Generally, you should use field_info_instance() instead, as it provides + * caching and allows other modules the opportunity to append additional + * formatters, widgets, and other information. + * + * @param $entity_type + * The type of entity to which the field is bound. + * @param $field_name + * The field name to read. + * @param $bundle + * The bundle to which the field is bound. + * @param array $include_additional + * The default behavior of this function is to not return an instance that has + * been deleted. Setting $include_additional['include_deleted'] to TRUE will + * override this behavior. + * + * @return + * An instance structure, or FALSE. + * + * @deprecated as of Drupal 8.0. Use + * entity_load('field_instance', 'field_name'). + */ +function field_read_instance($entity_type, $field_name, $bundle, $include_additional = array()) { + $instances = field_read_instances(array('entity_type' => $entity_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional); + return $instances ? current($instances) : FALSE; +} + +/** + * Reads in field instances that match an array of conditions. + * + * @param $param + * An array of properties to use in selecting a field instance. Keys are names + * of properties found in field instance configuration files, and values are + * conditions to match. + * @param $include_additional + * The default behavior of this function is to not return field instances that + * have been marked deleted. Setting + * $include_additional['include_deleted'] to TRUE will override this behavior. + * + * @return + * An array of instances matching the arguments. + * + * @deprecated as of Drupal 8.0. Use + * entity_load_multiple_by_properties('field_instance', $conditions). + */ +function field_read_instances($conditions = array(), $include_additional = array()) { + // Include deleted instances if specified either in the $include_additional + // or the $conditions parameters. + $include_deleted = (isset($include_additional['include_deleted']) && $include_additional['include_deleted']) || (isset($conditions['deleted']) && $conditions['deleted']); + + // Pass include_deleted to the $conditions array. + $conditions['include_deleted'] = $include_deleted; + + return entity_load_multiple_by_properties('field_instance', $conditions); +} + +/** * Adds form elements for all fields for an entity to a form structure. * * The form elements for the entity's fields are added by reference as direct