Commit 7562a8ef authored by webchick's avatar webchick

#707724 by chx: Rename confusing arguments in field/entity APIs.

parent 52195a6b
This diff is collapsed.
This diff is collapsed.
......@@ -41,7 +41,7 @@
* - field_name (string)
* The name of the field. Each field name is unique within Field API.
* When a field is attached to an object, the field's data is stored
* in $object->$field_name.
* in $entity->$field_name.
* - type (string)
* The type of the field, such as 'text' or 'image'. Field types
* are defined by modules that implement hook_field_info().
......@@ -553,9 +553,9 @@ function field_delete_field($field_name) {
// Delete all non-deleted instances.
$field = field_info_field($field_name);
if (isset($field['bundles'])) {
foreach ($field['bundles'] as $obj_type => $bundles) {
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
$instance = field_info_instance($obj_type, $field_name, $bundle);
$instance = field_info_instance($entity_type, $field_name, $bundle);
field_delete_instance($instance);
}
}
......@@ -786,7 +786,7 @@ function _field_write_instance($instance, $update = FALSE) {
* This function will not return deleted instances. Use
* field_read_instances() instead for this purpose.
*
* @param $obj_type
* @param $entity_type
* The type of object to which the field is bound.
* @param $field_name
* The field name to read.
......@@ -801,8 +801,8 @@ function _field_write_instance($instance, $update = FALSE) {
* @return
* An instance structure, or FALSE.
*/
function field_read_instance($obj_type, $field_name, $bundle, $include_additional = array()) {
$instances = field_read_instances(array('object_type' => $obj_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
function field_read_instance($entity_type, $field_name, $bundle, $include_additional = array()) {
$instances = field_read_instances(array('object_type' => $entity_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
return $instances ? current($instances) : FALSE;
}
......@@ -984,14 +984,14 @@ function field_purge_batch($batch_size) {
$field = field_info_field_by_id($instance['field_id']);
// Retrieve some pseudo-objects.
$obj_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), array('limit' => $batch_size));
$entity_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), array('limit' => $batch_size));
if (count($obj_types) > 0) {
if (count($entity_types) > 0) {
// Field data for the instance still exists.
foreach ($obj_types as $obj_type => $objects) {
field_attach_load($obj_type, $objects, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
foreach ($entity_types as $entity_type => $entities) {
field_attach_load($entity_type, $entities, FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
foreach ($objects as $id => $object) {
foreach ($entities as $id => $entity) {
// field_attach_query() may return more results than we asked for.
// Stop when he have done our batch size.
if ($batch_size-- <= 0) {
......@@ -999,7 +999,7 @@ function field_purge_batch($batch_size) {
}
// Purge the data for the object.
field_purge_data($obj_type, $object, $field, $instance);
field_purge_data($entity_type, $entity, $field, $instance);
}
}
}
......@@ -1027,28 +1027,28 @@ function field_purge_batch($batch_size) {
* to a single field. The object itself is not being deleted, and it is quite
* possible that other field data will remain attached to it.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entity
* The pseudo-object whose field data to delete.
* @param $field
* The (possibly deleted) field whose data is being purged.
* @param $instance
* The deleted field instance whose data is being purged.
*/
function field_purge_data($obj_type, $object, $field, $instance) {
function field_purge_data($entity_type, $entity, $field, $instance) {
// Each field type's hook_field_delete() only expects to operate on a single
// field at a time, so we can use it as-is for purging.
$options = array('field_id' => $instance['field_id'], 'deleted' => TRUE);
_field_invoke('delete', $obj_type, $object, $dummy, $dummy, $options);
_field_invoke('delete', $entity_type, $entity, $dummy, $dummy, $options);
// Tell the field storage system to purge the data.
module_invoke($field['storage']['module'], 'field_storage_purge', $obj_type, $object, $field, $instance);
module_invoke($field['storage']['module'], 'field_storage_purge', $entity_type, $entity, $field, $instance);
// Let other modules act on purging the data.
foreach (module_implements('field_attach_purge') as $module) {
$function = $module . '_field_attach_purge';
$function($obj_type, $object, $field, $instance);
$function($entity_type, $entity, $field, $instance);
}
}
......
......@@ -11,7 +11,7 @@
* the corresponding field_attach_[operation]() function.
*/
function field_default_extract_form_values($obj_type, $object, $field, $instance, $langcode, &$items, $form, &$form_state) {
function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
$field_name = $field['field_name'];
if (isset($form_state['values'][$field_name][$langcode])) {
......@@ -29,18 +29,18 @@ function field_default_extract_form_values($obj_type, $object, $field, $instance
*
* @see _hook_field_validate()
*
* @param $obj_type
* The type of $object.
* @param $object
* @param $entity_type
* The type of $entity.
* @param $entity
* The object for the operation.
* @param $field
* The field structure for the operation.
* @param $instance
* The instance structure for $field on $object's bundle.
* The instance structure for $field on $entity's bundle.
* @param $langcode
* The language associated to $items.
* @param $items
* $object->{$field['field_name']}[$langcode], or an empty array if unset.
* $entity->{$field['field_name']}[$langcode], or an empty array if unset.
* @param $errors
* The array of errors, keyed by field name and by value delta, that have
* already been reported for the object. The function should add its errors
......@@ -49,7 +49,7 @@ function field_default_extract_form_values($obj_type, $object, $field, $instance
* - 'error': an error code (should be a string, prefixed with the module name)
* - 'message': the human readable message to be displayed.
*/
function field_default_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
function field_default_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
// Filter out empty values.
$items = _field_filter_items($field, $items);
......@@ -64,7 +64,7 @@ function field_default_validate($obj_type, $object, $field, $instance, $langcode
}
}
function field_default_submit($obj_type, $object, $field, $instance, $langcode, &$items, $form, &$form_state) {
function field_default_submit($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
$field_name = $field['field_name'];
// Reorder items to account for drag-n-drop reordering.
......@@ -79,29 +79,29 @@ function field_default_submit($obj_type, $object, $field, $instance, $langcode,
/**
* Default field 'insert' operation.
*
* Insert default value if no $object->$field_name entry was provided.
* Insert default value if no $entity->$field_name entry was provided.
* This can happen with programmatic saves, or on form-based creation where
* the current user doesn't have 'edit' permission for the field.
*/
function field_default_insert($obj_type, $object, $field, $instance, $langcode, &$items) {
// _field_invoke() populates $items with an empty array if the $object has no
// entry for the field, so we check on the $object itself.
function field_default_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
// _field_invoke() populates $items with an empty array if the $entity has no
// entry for the field, so we check on the $entity itself.
// We also check that the current field translation is actually defined before
// assigning it a default value. This way we ensure that only the intended
// languages get a default value. Otherwise we could have default values for
// not yet open languages.
if (empty($object) || !property_exists($object, $field['field_name']) ||
(isset($object->{$field['field_name']}[$langcode]) && count($object->{$field['field_name']}[$langcode]) == 0)) {
$items = field_get_default_value($obj_type, $object, $field, $instance, $langcode);
if (empty($entity) || !property_exists($entity, $field['field_name']) ||
(isset($entity->{$field['field_name']}[$langcode]) && count($entity->{$field['field_name']}[$langcode]) == 0)) {
$items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
}
}
/**
* Invokes hook_field_formatter_prepare_view() on the relevant formatters.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $objects
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entities
* An array of objects being displayed, keyed by object id.
* @param $field
* The field structure for the operation.
......@@ -118,7 +118,7 @@ function field_default_insert($obj_type, $object, $field, $instance, $langcode,
* - or an array of display settings to use for display, as found in the
* 'display' entry of $instance definitions.
*/
function field_default_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $display) {
function field_default_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $display) {
// Group objects, instances and items by formatter module.
$modules = array();
foreach ($instances as $id => $instance) {
......@@ -126,7 +126,7 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
if ($display['type'] !== 'hidden') {
$module = $display['module'];
$modules[$module] = $module;
$grouped_objects[$module][$id] = $objects[$id];
$grouped_objects[$module][$id] = $entities[$id];
$grouped_instances[$module][$id] = $instance;
$grouped_displays[$module][$id] = $display;
// hook_field_formatter_prepare_view() alters $items by reference.
......@@ -138,7 +138,7 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
// Invoke hook_field_formatter_prepare_view().
$function = $module . '_field_formatter_prepare_view';
if (function_exists($function)) {
$function($obj_type, $grouped_objects[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
$function($entity_type, $grouped_objects[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]);
}
}
}
......@@ -146,9 +146,9 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
/**
* Builds a renderable array for field values.
*
* @param $obj_type
* The type of $object; e.g. 'node' or 'user'.
* @param $objects
* @param $entity_type
* The type of $entity; e.g. 'node' or 'user'.
* @param $entities
* An array of objects being displayed, keyed by object id.
* @param $field
* The field structure for the operation.
......@@ -165,8 +165,8 @@ function field_default_prepare_view($obj_type, $objects, $field, $instances, $la
* - or an array of custom display settings, as found in the 'display' entry
* of $instance definitions.
*/
function field_default_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$addition = array();
......@@ -189,23 +189,23 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
// performance impact on pages with many fields and values.
$function = $display['module'] . '_field_formatter_view';
if (function_exists($function)) {
$elements = $function($obj_type, $object, $field, $instance, $langcode, $items, $display);
$elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display);
if ($elements) {
$info = array(
'#theme' => 'field',
'#weight' => $display['weight'],
'#title' => t($instance['label']),
'#access' => field_access('view', $field, $obj_type, $object),
'#access' => field_access('view', $field, $entity_type, $entity),
'#label_display' => $display['label'],
'#view_mode' => $view_mode,
'#language' => $langcode,
'#field_name' => $field['field_name'],
'#field_type' => $field['type'],
'#field_translatable' => $field['translatable'],
'#object_type' => $obj_type,
'#object_type' => $entity_type,
'#bundle' => $bundle,
'#object' => $object,
'#object' => $entity,
'#items' => $items,
'#formatter' => $display['type']
);
......@@ -218,10 +218,10 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
return $addition;
}
function field_default_prepare_translation($obj_type, $object, $field, $instance, $langcode, &$items) {
function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items) {
$addition = array();
if (isset($object->translation_source->$field['field_name'])) {
$addition[$field['field_name']] = $object->translation_source->$field['field_name'];
if (isset($entity->translation_source->$field['field_name'])) {
$addition[$field['field_name']] = $entity->translation_source->$field['field_name'];
}
return $addition;
}
......@@ -9,11 +9,11 @@
/**
* Create a separate form element for each field.
*/
function field_default_form($obj_type, $object, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
function field_default_form($entity_type, $entity, $field, $instance, $langcode, $items, &$form, &$form_state, $get_delta = NULL) {
// This could be called with no object, as when a UI module creates a
// dummy form to set default values.
if ($object) {
list($id, , ) = entity_extract_ids($obj_type, $object);
if ($entity) {
list($id, , ) = entity_extract_ids($entity_type, $entity);
}
$field_name = $field['field_name'];
......@@ -31,12 +31,12 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
// Populate widgets with default values when creating a new object.
if (empty($items) && empty($id)) {
$items = field_get_default_value($obj_type, $object, $field, $instance, $langcode);
$items = field_get_default_value($entity_type, $entity, $field, $instance, $langcode);
}
// Collect widget elements.
$elements = array();
if (field_access('edit', $field, $obj_type, $object)) {
if (field_access('edit', $field, $entity_type, $entity)) {
// If field module handles multiple values for this form element, and we
// are displaying an individual element, process the multiple value form.
if (!isset($get_delta) && field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
......@@ -325,7 +325,7 @@ function field_form_element_after_build($element, &$form_state) {
/**
* Transfer field-level validation errors to widgets.
*/
function field_default_form_errors($obj_type, $object, $field, $instance, $langcode, $items, $form, &$form_state) {
function field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state) {
$field_name = $field['field_name'];
$field_info = $form_state['field'][$field_name][$langcode];
......
......@@ -208,9 +208,9 @@ function _field_info_collate_fields($reset = FALSE) {
// Populate 'instances'. Only non-deleted instances are considered.
$info['instances'] = array();
foreach (field_info_bundles() as $obj_type => $bundles) {
foreach (field_info_bundles() as $entity_type => $bundles) {
foreach ($bundles as $bundle => $bundle_info) {
$info['instances'][$obj_type][$bundle] = array();
$info['instances'][$entity_type][$bundle] = array();
}
}
foreach ($definitions['instances'] as $instance) {
......@@ -481,19 +481,19 @@ function field_info_storage_types($storage_type = NULL) {
/**
* Returns information about existing bundles.
*
* @param $obj_type
* @param $entity_type
* The type of object; e.g. 'node' or 'user'.
*
* @return
* An array of bundles for the $obj_type keyed by bundle name,
* or, if no $obj_type was provided, the array of all existing bundles,
* An array of bundles for the $entity_type keyed by bundle name,
* or, if no $entity_type was provided, the array of all existing bundles,
* keyed by object type.
*/
function field_info_bundles($obj_type = NULL) {
function field_info_bundles($entity_type = NULL) {
$info = entity_get_info();
if ($obj_type) {
return isset($info[$obj_type]['bundles']) ? $info[$obj_type]['bundles'] : array();
if ($entity_type) {
return isset($info[$entity_type]['bundles']) ? $info[$entity_type]['bundles'] : array();
}
$bundles = array();
......@@ -561,27 +561,27 @@ function field_info_field_by_id($field_id) {
/**
* Retrieves information about field instances.
*
* @param $obj_type
* @param $entity_type
* The object type for which to return instances.
* @param $bundle_name
* The bundle name for which to return instances.
*
* @return
* If $obj_type is not set, return all instances keyed by object type and
* bundle name. If $obj_type is set, return all instances for that object
* type, keyed by bundle name. If $obj_type and $bundle_name are set, return
* If $entity_type is not set, return all instances keyed by object type and
* bundle name. If $entity_type is set, return all instances for that object
* type, keyed by bundle name. If $entity_type and $bundle_name are set, return
* all instances for that bundle.
*/
function field_info_instances($obj_type = NULL, $bundle_name = NULL) {
function field_info_instances($entity_type = NULL, $bundle_name = NULL) {
$info = _field_info_collate_fields();
if (!isset($obj_type)) {
if (!isset($entity_type)) {
return $info['instances'];
}
if (!isset($bundle_name)) {
return $info['instances'][$obj_type];
return $info['instances'][$entity_type];
}
if (isset($info['instances'][$obj_type][$bundle_name])) {
return $info['instances'][$obj_type][$bundle_name];
if (isset($info['instances'][$entity_type][$bundle_name])) {
return $info['instances'][$entity_type][$bundle_name];
}
return array();
}
......@@ -589,17 +589,17 @@ function field_info_instances($obj_type = NULL, $bundle_name = NULL) {
/**
* Returns an array of instance data for a specific field and bundle.
*
* @param $obj_type
* @param $entity_type
* The object type for the instance.
* @param $field_name
* The field name for the instance.
* @param $bundle_name
* The bundle name for the instance.
*/
function field_info_instance($obj_type, $field_name, $bundle_name) {
function field_info_instance($entity_type, $field_name, $bundle_name) {
$info = _field_info_collate_fields();
if (isset($info['instances'][$obj_type][$bundle_name][$field_name])) {
return $info['instances'][$obj_type][$bundle_name][$field_name];
if (isset($info['instances'][$entity_type][$bundle_name][$field_name])) {
return $info['instances'][$entity_type][$bundle_name][$field_name];
}
}
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ function field_multilingual_settings_changed() {
* only entities that are able to handle translations actually get translatable
* fields.
*
* @param $obj_type
* @param $entity_type
* The type of the entity the field is attached to, e.g. 'node' or 'user'.
* @param $field
* A field structure.
......@@ -33,12 +33,12 @@ function field_multilingual_settings_changed() {
* @return
* An array of valid language codes.
*/
function field_multilingual_available_languages($obj_type, $field, $suggested_languages = NULL) {
function field_multilingual_available_languages($entity_type, $field, $suggested_languages = NULL) {
$field_languages = &drupal_static(__FUNCTION__, array());
$field_name = $field['field_name'];
if (!isset($field_languages[$field_name]) || !empty($suggested_languages)) {
$translation_handlers = field_multilingual_check_translation_handlers($obj_type);
$translation_handlers = field_multilingual_check_translation_handlers($entity_type);
if ($translation_handlers && $field['translatable']) {
// The returned languages are a subset of the intersection of enabled ones
......@@ -48,7 +48,7 @@ function field_multilingual_available_languages($obj_type, $field, $suggested_la
foreach (module_implements('field_languages') as $module) {
$function = $module . '_field_languages';
$function($obj_type, $field, $languages);
$function($entity_type, $field, $languages);
}
// Accept only available languages.
$result = array_values(array_intersect($available_languages, $languages));
......@@ -86,7 +86,7 @@ function field_multilingual_content_languages() {
* If no handler is passed, simply check if there is any translation handler
* enabled for the given entity type.
*
* @param $obj_type
* @param $entity_type
* The type of the entity whose fields are to be translated.
* @param $handler
* The name of the handler to be checked.
......@@ -94,8 +94,8 @@ function field_multilingual_content_languages() {
* @return
* TRUE, if the handler is allowed to manage field translations.
*/
function field_multilingual_check_translation_handlers($obj_type, $handler = NULL) {
$obj_info = entity_get_info($obj_type);
function field_multilingual_check_translation_handlers($entity_type, $handler = NULL) {
$obj_info = entity_get_info($entity_type);
if (isset($handler)) {
return isset($obj_info['translation'][$handler]) && !empty($obj_info['translation'][$handler]);
......
......@@ -88,18 +88,18 @@ function _field_sql_storage_indexname($name, $index) {
/**
* Retrieve or assign an entity type id for an object type.
*
* @param $obj_type
* @param $entity_type
* The object type, such as 'node' or 'user'.
* @return
* The entity type id.
*
* TODO: We need to decide on 'entity' or 'object'.
*/
function _field_sql_storage_etid($obj_type) {
$etid = variable_get('field_sql_storage_' . $obj_type . '_etid', NULL);
function _field_sql_storage_etid($entity_type) {
$etid = variable_get('field_sql_storage_' . $entity_type . '_etid', NULL);
if (is_null($etid)) {
$etid = db_insert('field_config_entity_type')->fields(array('type' => $obj_type))->execute();
variable_set('field_sql_storage_' . $obj_type . '_etid', $etid);
$etid = db_insert('field_config_entity_type')->fields(array('type' => $entity_type))->execute();
variable_set('field_sql_storage_' . $entity_type . '_etid', $etid);
}
return $etid;
}
......@@ -299,8 +299,8 @@ function field_sql_storage_field_storage_delete_field($field) {
/**
* Implements hook_field_storage_load().
*/
function field_sql_storage_field_storage_load($obj_type, $objects, $age, $fields, $options) {
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fields, $options) {
$etid = _field_sql_storage_etid($entity_type);
$load_current = $age == FIELD_LOAD_CURRENT;
foreach ($fields as $field_id => $ids) {
......@@ -312,7 +312,7 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age, $fields
->fields('t')
->condition('etid', $etid)
->condition($load_current ? 'entity_id' : 'revision_id', $ids, 'IN')
->condition('language', field_multilingual_available_languages($obj_type, $field), 'IN')
->condition('language', field_multilingual_available_languages($entity_type, $field), 'IN')
->orderBy('delta');
if (empty($options['deleted'])) {
......@@ -337,7 +337,7 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age, $fields
}
// Add the item to the field values for the entity.
$objects[$row->entity_id]->{$field_name}[$row->language][] = $item;
$entities[$row->entity_id]->{$field_name}[$row->language][] = $item;
$delta_count[$row->entity_id][$row->language]++;
}
}
......@@ -347,9 +347,9 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age, $fields
/**
* Implements hook_field_storage_write().
*/
function field_sql_storage_field_storage_write($obj_type, $object, $op, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_storage_write($entity_type, $entity, $op, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$etid = _field_sql_storage_etid($entity_type);
foreach ($fields as $field_id) {
$field = field_info_field_by_id($field_id);
......@@ -357,14 +357,14 @@ function field_sql_storage_field_storage_write($obj_type, $object, $op, $fields)
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
$all_languages = field_multilingual_available_languages($obj_type, $field);
$field_languages = array_intersect($all_languages, array_keys((array) $object->$field_name));
$all_languages = field_multilingual_available_languages($entity_type, $field);
$field_languages = array_intersect($all_languages, array_keys((array) $entity->$field_name));
// Delete and insert, rather than update, in case a value was added.
if ($op == FIELD_STORAGE_UPDATE) {
// Delete languages present in the incoming $object->$field_name.
// Delete all languages if $object->$field_name is empty.
$languages = !empty($object->$field_name) ? $field_languages : $all_languages;
// Delete languages present in the incoming $entity->$field_name.
// Delete all languages if $entity->$field_name is empty.
$languages = !empty($entity->$field_name) ? $field_languages : $all_languages;
if ($languages) {
db_delete($table_name)
->condition('etid', $etid)
......@@ -394,7 +394,7 @@ function field_sql_storage_field_storage_write($obj_type, $object, $op, $fields)
}
foreach ($field_languages as $langcode) {
$items = (array) $object->{$field_name}[$langcode];
$items = (array) $entity->{$field_name}[$langcode];
$delta_count = 0;
foreach ($items as $delta => $item) {
// We now know we have someting to insert.
......@@ -436,14 +436,14 @@ function field_sql_storage_field_storage_write($obj_type, $object, $op, $fields)
*
* This function deletes data for all fields for an object from the database.
*/
function field_sql_storage_field_storage_delete($obj_type, $object, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_storage_delete($entity_type, $entity, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$etid = _field_sql_storage_etid($entity_type);
foreach (field_info_instances($obj_type, $bundle) as $instance) {
foreach (field_info_instances($entity_type, $bundle) as $instance) {
if (isset($fields[$instance['field_id']])) {
$field = field_info_field_by_id($instance['field_id']);
field_sql_storage_field_storage_purge($obj_type, $object, $field, $instance);
field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance);
}
}
}
......@@ -454,9 +454,9 @@ function field_sql_storage_field_storage_delete($obj_type, $object, $fields) {
* This function deletes data from the database for a single field on
* an object.
*/
function field_sql_storage_field_storage_purge($obj_type, $object, $field, $instance) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$etid = _field_sql_storage_etid($entity_type);
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
......@@ -597,9 +597,9 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $options)
*
* This function actually deletes the data from the database.
*/
function field_sql_storage_field_storage_delete_revision($obj_type, $object, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_storage_delete_revision($entity_type, $entity, $fields) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$etid = _field_sql_storage_etid($entity_type);
if (isset($vid)) {
foreach ($fields as $field_id) {
......@@ -639,10 +639,10 @@ function field_sql_storage_field_storage_delete_instance($instance) {
/**
* Implements hook_field_attach_rename_bundle().
*/
function field_sql_storage_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) {
$etid = _field_sql_storage_etid($obj_type);
function field_sql_storage_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
$etid = _field_sql_storage_etid($entity_type);
// We need to account for deleted or inactive fields and instances.
$instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$instances = field_read_instances(array('object_type' => $entity_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
foreach ($instances as $instance) {
$field = field_info_field_by_id($instance['field_id']);
if ($field['storage']['type'] == 'field_sql_storage') {
......
......@@ -184,7 +184,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$this->assertTrue(empty($rev_values), "All values for all revisions are stored in revision table {$this->revision_table}");
// Check that update leaves the field data untouched if
// $object->{$field_name} is absent.
// $entity->{$field_name} is absent.
unset($entity->{$this->field_name});
field_attach_update($entity_type, $entity);
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
......@@ -194,7 +194,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
}
}
// Check that update with an empty $object->$field_name empties the field.
// Check that update with an empty $entity->$field_name empties the field.
$entity->{$this->field_name} = NULL;
field_attach_update($entity_type, $entity);
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
......
......@@ -262,7 +262,7 @@ function list_extract_allowed_values($string_values, $position_keys = FALSE) {
* Possible error codes:
* - 'list_illegal_value': The value is not part of the list of allowed values.
*/
function list_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
function list_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
$allowed_values = list_allowed_values($field);
foreach ($items as $delta => $item) {
if (!empty($item['value'])) {
......@@ -332,7 +332,7 @@ function list_field_formatter_info() {
/**
* Implements hook_field_formatter_view().
*/
function list_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
function list_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
......
......@@ -176,7 +176,7 @@ function number_field_instance_settings_form($field, $instance) {
* - 'number_min': The value is smaller than the allowed minimum value.
* - 'number_max': The value is larger than the allowed maximum value.
*/
function number_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {
function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) {
if ($item['value'] != '') {
if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) {
......@@ -198,7 +198,7 @@ function number_field_validate($obj_type, $object, $field, $instance, $langcode,
/**
* Implements hook_field_presave().
*/
function number_field_presave($obj_type, $object, $field, $instance, $langcode, &$items) {
function number_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] == 'number_decimal') {