Issue #2019147 by swentel, andypost: Mark functions in field.info.inc deprecated.

8.0.x
Dries 2013-06-27 08:12:11 -04:00
parent 4cdff73768
commit a5ae85b347
3 changed files with 54 additions and 4 deletions

View File

@ -41,6 +41,9 @@ use Drupal\field\FieldException;
*
* @return
* A field definition array, or FALSE.
*
* @deprecated as of Drupal 8.0. Use
* entity_load('field_entity', 'field_name').
*/
function field_read_field($field_name, $include_additional = array()) {
$fields = field_read_fields(array('field_name' => $field_name), $include_additional);
@ -63,6 +66,9 @@ function field_read_field($field_name, $include_additional = array()) {
* 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 inactive fields if specified in the $include_additional parameter.
@ -99,6 +105,9 @@ function field_read_fields($conditions = array(), $include_additional = array())
*
* @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);
@ -120,6 +129,9 @@ function field_read_instance($entity_type, $field_name, $bundle, $include_additi
*
* @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 instances of inactive fields if specified in the

View File

@ -155,6 +155,9 @@ function field_behaviors_widget($op, $instance) {
* ),
* );
* @endcode
*
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getFieldMap().
*/
function field_info_field_map() {
return Field::fieldInfo()->getFieldMap();
@ -292,6 +295,9 @@ function field_info_fields() {
* found.
*
* @see field_info_field_by_id()
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getField($field_name).
*/
function field_info_field($field_name) {
return Field::fieldInfo()->getField($field_name);
@ -310,6 +316,9 @@ function field_info_field($field_name) {
* belongs to.
*
* @see field_info_field()
*
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getFieldById($field_id).
*/
function field_info_field_by_id($field_id) {
return Field::fieldInfo()->getFieldById($field_id);
@ -332,6 +341,9 @@ function field_info_field_by_id($field_id) {
*
* @see field_info_field()
* @see field_info_field_by_id()
*
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getFields().
*/
function field_info_field_by_ids() {
return Field::fieldInfo()->getFields();
@ -361,6 +373,11 @@ function field_info_field_by_ids() {
* bundle name. If $entity_type is set, return all instances for that entity
* type, keyed by bundle name. If $entity_type and $bundle_name are set,
* return all instances for that bundle.
*
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getInstances(),
* Field::fieldInfo()->getInstances($entity_type) or
* Field::fieldInfo()->getBundleInstances($entity_type, $bundle_name).
*/
function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
$cache = Field::fieldInfo();
@ -393,12 +410,12 @@ function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
* @return
* An associative array of instance data for the specific field and bundle;
* NULL if the instance does not exist.
*
* @deprecated as of Drupal 8.0. Use
* Field::fieldInfo()->getBundleInstance($entity_type, $bundle, $field_name).
*/
function field_info_instance($entity_type, $field_name, $bundle_name) {
$info = Field::fieldInfo()->getBundleInstances($entity_type, $bundle_name);
if (isset($info[$field_name])) {
return $info[$field_name];
}
return Field::fieldInfo()->getInstance($entity_type, $bundle_name, $field_name);
}
/**

View File

@ -480,6 +480,27 @@ class FieldInfo {
return $instances;
}
/**
* Returns an array of instance data for a specific field and bundle.
*
* @param string $entity_type
* The entity type for the instance.
* @param string $bundle
* The bundle name for the instance.
* @param string $field_name
* The field name for the instance.
*
* @return array
* An associative array of instance data for the specific field and bundle;
* NULL if the instance does not exist.
*/
function getInstance($entity_type, $bundle, $field_name) {
$info = $this->getBundleInstances($entity_type, $bundle);
if (isset($info[$field_name])) {
return $info[$field_name];
}
}
/**
* Retrieves the "extra fields" for a bundle.
*