diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-02-11 17:44:47 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-02-11 17:44:47 +0000 |
commit | 7562a8efb36306e96bf4d13b1f97b4573809ab45 (patch) | |
tree | 998dfd1d27d9c1a691a83a0c0e37d783d4fc4a44 /modules | |
parent | 52195a6b1dd478875a93935df27d7bcacb14f289 (diff) | |
download | brdo-7562a8efb36306e96bf4d13b1f97b4573809ab45.tar.gz brdo-7562a8efb36306e96bf4d13b1f97b4573809ab45.tar.bz2 |
#707724 by chx: Rename confusing arguments in field/entity APIs.
Diffstat (limited to 'modules')
32 files changed, 764 insertions, 764 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php index 3441259f1..4a98eeba8 100644 --- a/modules/field/field.api.php +++ b/modules/field/field.api.php @@ -242,7 +242,7 @@ function hook_field_schema($field) { * Defines custom load behavior for this module's field types. * * Unlike most other field hooks, this hook operates on multiple objects. The - * $objects, $instances and $items parameters are arrays keyed by object id. + * $entities, $instances and $items parameters are arrays keyed by object id. * For performance reasons, information for all available objects should be * loaded in a single query where possible. * @@ -252,9 +252,9 @@ function hook_field_schema($field) { * hook_field_load() is run on those as well. Use * hook_field_formatter_prepare_view() instead. * - * @param $obj_type - * The type of $object. - * @param $objects + * @param $entity_type + * The type of $entity. + * @param $entities * Array of objects being loaded, keyed by object id. * @param $field * The field structure for the operation. @@ -272,10 +272,10 @@ function hook_field_schema($field) { * Changes or additions to field values are done by altering the $items * parameter by reference. */ -function hook_field_load($obj_type, $objects, $field, $instances, $langcode, &$items, $age) { +function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { // Sample code from text.module: precompute sanitized strings so they are // stored in the field cache. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Only process items with a cacheable format, the rest will be handled // by formatters if needed. @@ -298,13 +298,13 @@ function hook_field_load($obj_type, $objects, $field, $instances, $langcode, &$i * @see hook_field_formatter_prepare_view() * * Unlike most other field hooks, this hook operates on multiple objects. The - * $objects, $instances and $items parameters are arrays keyed by object id. + * $entities, $instances and $items parameters are arrays keyed by object id. * For performance reasons, information for all available objects should be * loaded in a single query where possible. * - * @param $obj_type - * The type of $object. - * @param $objects + * @param $entity_type + * The type of $entity. + * @param $entities * Array of objects being displayed, keyed by object id. * @param $field * The field structure for the operation. @@ -314,12 +314,12 @@ function hook_field_load($obj_type, $objects, $field, $instances, $langcode, &$i * @param $langcode * The language associated to $items. * @param $items - * $object->{$field['field_name']}, or an empty array if unset. + * $entity->{$field['field_name']}, or an empty array if unset. */ -function hook_field_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items) { +function hook_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { // Sample code from image.module: if there are no images specified at all, // use the default. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { if (empty($items[$id]) && $field['settings']['default_image']) { if ($file = file_load($field['settings']['default_image'])) { $items[$id][0] = (array) $file + array( @@ -335,18 +335,18 @@ function hook_field_prepare_view($obj_type, $objects, $field, $instances, $langc /** * Define custom validate behavior for this module's field types. * - * @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 @@ -355,7 +355,7 @@ function hook_field_prepare_view($obj_type, $objects, $field, $instances, $langc * - 'error': an error code (should be a string, prefixed with the module name) * - 'message': the human readable message to be displayed. */ -function hook_field_validate($obj_type, $object, $field, $instance, $langcode, &$items, &$errors) { +function hook_field_validate($entity_type, $entity, $field, $instance, $langcode, &$items, &$errors) { foreach ($items as $delta => $item) { if (!empty($item['value'])) { if (!empty($field['settings']['max_length']) && drupal_strlen($item['value']) > $field['settings']['max_length']) { @@ -371,20 +371,20 @@ function hook_field_validate($obj_type, $object, $field, $instance, $langcode, & /** * Define custom presave behavior for this module's field types. * - * @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. */ -function hook_field_presave($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { if ($field['type'] == 'number_decimal') { // Let PHP round the value to ensure consistent behavior across storage // backends. @@ -399,39 +399,39 @@ function hook_field_presave($obj_type, $object, $field, $instance, $langcode, &$ /** * Define custom insert behavior for this module's field types. * - * @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. */ -function hook_field_insert($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { } /** * Define custom update behavior for this module's field types. * - * @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. */ -function hook_field_update($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { } /** @@ -439,20 +439,20 @@ function hook_field_update($obj_type, $object, $field, $instance, $langcode, &$i * * This hook is invoked just before the data is deleted from field storage. * - * @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. */ -function hook_field_delete($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { } /** @@ -461,20 +461,20 @@ function hook_field_delete($obj_type, $object, $field, $instance, $langcode, &$i * This hook is invoked just before the data is deleted from field storage, * and will only be called for fieldable types that are versioned. * - * @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. */ -function hook_field_delete_revision($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { } /** @@ -482,20 +482,20 @@ function hook_field_delete_revision($obj_type, $object, $field, $instance, $lang * * TODO: This hook may or may not survive in Field API. * - * @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. */ -function hook_field_prepare_translation($obj_type, $object, $field, $instance, $langcode, &$items) { +function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items) { } /** @@ -775,13 +775,13 @@ function hook_field_formatter_info_alter(&$info) { * @see hook_field_prepare_view() * * Unlike most other field hooks, this hook operates on multiple objects. The - * $objects, $instances and $items parameters are arrays keyed by object id. + * $entities, $instances and $items parameters are arrays keyed by object id. * For performance reasons, information for all available objects should be * loaded in a single query where possible. * - * @param $obj_type - * The type of $object. - * @param $objects + * @param $entity_type + * The type of $entity. + * @param $entities * Array of objects being displayed, keyed by object id. * @param $field * The field structure for the operation. @@ -799,16 +799,16 @@ function hook_field_formatter_info_alter(&$info) { * Changes or additions to field values are done by altering the $items * parameter by reference. */ -function hook_field_formatter_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $displays) { +function hook_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { } /** * Builds a renderable array for a field value. * - * @param $obj_type - * The type of $object. - * @param $object + * @param $entity_type + * The type of $entity. + * @param $entity * The object being displayed. * @param $field * The field structure. @@ -828,7 +828,7 @@ function hook_field_formatter_prepare_view($obj_type, $objects, $field, $instanc * A renderable array for the $items, as an array of child elements keyed * by numeric indexes starting from 0. */ -function hook_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) { +function hook_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); $settings = $display['settings']; @@ -888,11 +888,11 @@ function hook_field_formatter_view($obj_type, $object, $field, $instance, $langc * * See field_attach_form() for details and arguments. */ -function hook_field_attach_form($obj_type, $object, &$form, &$form_state, $langcode) { +function hook_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { $tids = array(); // Collect every possible term attached to any of the fieldable entities. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Force the array key to prevent duplicates. $tids[$item['value']] = $item['value']; @@ -910,7 +910,7 @@ function hook_field_attach_form($obj_type, $object, &$form, &$form_state, $langc $terms = $query->execute()->fetchAllAssoc('tid'); // Iterate through the fieldable entities again to attach the loaded term data. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Check whether the taxonomy term field instance value could be loaded. if (isset($terms[$item['value']])) { @@ -932,7 +932,7 @@ function hook_field_attach_form($obj_type, $object, &$form, &$form_state, $langc * This hook is invoked after the field module has performed the operation. * * Unlike other field_attach hooks, this hook accounts for 'multiple loads'. - * Instead of the usual $object parameter, it accepts an array of objects, + * Instead of the usual $entity parameter, it accepts an array of objects, * indexed by object id. For performance reasons, information for all available * objects should be loaded in a single query where possible. * @@ -941,7 +941,7 @@ function hook_field_attach_form($obj_type, $object, &$form, &$form_state, $langc * * See field_attach_load() for details and arguments. */ -function hook_field_attach_load($obj_type, $objects, $age) { +function hook_field_attach_load($entity_type, $entities, $age) { } /** @@ -951,7 +951,7 @@ function hook_field_attach_load($obj_type, $objects, $age) { * * See field_attach_validate() for details and arguments. */ -function hook_field_attach_validate($obj_type, $object, &$errors) { +function hook_field_attach_validate($entity_type, $entity, &$errors) { } /** @@ -961,7 +961,7 @@ function hook_field_attach_validate($obj_type, $object, &$errors) { * * See field_attach_submit() for details and arguments. */ -function hook_field_attach_submit($obj_type, $object, $form, &$form_state) { +function hook_field_attach_submit($entity_type, $entity, $form, &$form_state) { } /** @@ -971,7 +971,7 @@ function hook_field_attach_submit($obj_type, $object, $form, &$form_state) { * * See field_attach_presave() for details and arguments. */ -function hook_field_attach_presave($obj_type, $object) { +function hook_field_attach_presave($entity_type, $entity) { } /** @@ -981,7 +981,7 @@ function hook_field_attach_presave($obj_type, $object) { * * See field_attach_insert() for details and arguments. */ -function hook_field_attach_insert($obj_type, $object) { +function hook_field_attach_insert($entity_type, $entity) { } /** @@ -991,7 +991,7 @@ function hook_field_attach_insert($obj_type, $object) { * * See field_attach_update() for details and arguments. */ -function hook_field_attach_update($obj_type, $object) { +function hook_field_attach_update($entity_type, $entity) { } /** @@ -1004,7 +1004,7 @@ function hook_field_attach_update($obj_type, $object) { * values. * @param $context * An associative array containing: - * - obj_type: The type of $object; e.g. 'node' or 'user'. + * - obj_type: The type of $entity; e.g. 'node' or 'user'. * - object: The object with fields to render. * - element: The structured array containing the values ready for rendering. */ @@ -1018,7 +1018,7 @@ function hook_field_attach_preprocess_alter(&$variables, $context) { * * See field_attach_delete() for details and arguments. */ -function hook_field_attach_delete($obj_type, $object) { +function hook_field_attach_delete($entity_type, $entity) { } /** @@ -1028,7 +1028,7 @@ function hook_field_attach_delete($obj_type, $object) { * * See field_attach_delete_revision() for details and arguments. */ -function hook_field_attach_delete_revision($obj_type, $object) { +function hook_field_attach_delete_revision($entity_type, $entity) { } /** @@ -1037,10 +1037,10 @@ function hook_field_attach_delete_revision($obj_type, $object) { * This hook is invoked after the field module has performed the operation. * * @param &$output - * The structured content array tree for all of $object's fields. + * The structured content array tree for all of $entity's fields. * @param $context * An associative array containing: - * - obj_type: The type of $object; e.g. 'node' or 'user'. + * - obj_type: The type of $entity; e.g. 'node' or 'user'. * - object: The object with fields to render. * - view_mode: View mode, e.g. 'full', 'teaser'... * - langcode: The language in which the field values will be displayed. @@ -1055,7 +1055,7 @@ function hook_field_attach_view_alter(&$output, $context) { * * See field_attach_create_bundle() for details and arguments. */ -function hook_field_attach_create_bundle($obj_type, $bundle) { +function hook_field_attach_create_bundle($entity_type, $bundle) { } /** @@ -1065,7 +1065,7 @@ function hook_field_attach_create_bundle($obj_type, $bundle) { * * See field_attach_rename_bundle() for details and arguments. */ -function hook_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { +function hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { } /** @@ -1073,7 +1073,7 @@ function hook_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { * * This hook is invoked after the field module has performed the operation. * - * @param $obj_type + * @param $entity_type * The type of object; e.g. 'node' or 'user'. * @param $bundle * The bundle that was just deleted. @@ -1081,7 +1081,7 @@ function hook_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { * An array of all instances that existed for the bundle before it was * deleted. */ -function hook_field_attach_delete_bundle($obj_type, $bundle, $instances) { +function hook_field_attach_delete_bundle($entity_type, $bundle, $instances) { } /** @@ -1173,9 +1173,9 @@ function hook_field_storage_details_alter(&$details, $field) { /** * Load field data for a set of objects. * - * @param $obj_type + * @param $entity_type * The entity type of object, such as 'node' or 'user'. - * @param $objects + * @param $entities * The array of objects for which to load data, keyed by object id. * @param $age * FIELD_LOAD_CURRENT to load the most recent revision for all @@ -1186,18 +1186,18 @@ function hook_field_storage_details_alter(&$details, $field) { * ids, the values of the array are the object ids (or revision ids, * depending on the $age parameter) to be loaded for each field. * @return - * Loaded field values are added to $objects. Fields with no values should be + * Loaded field values are added to $entities. Fields with no values should be * set as an empty array. */ -function hook_field_storage_load($obj_type, $objects, $age, $fields) { +function hook_field_storage_load($entity_type, $entities, $age, $fields) { } /** * Write field data for an object. * - * @param $obj_type + * @param $entity_type * The entity type of object, such as 'node' or 'user'. - * @param $object + * @param $entity * The object on which to operate. * @param $op * FIELD_STORAGE_UPDATE when updating an existing object, @@ -1206,21 +1206,21 @@ function hook_field_storage_load($obj_type, $objects, $age, $fields) { * An array listing the fields to be written. The keys and values of the * array are field ids. */ -function hook_field_storage_write($obj_type, $object, $op, $fields) { +function hook_field_storage_write($entity_type, $entity, $op, $fields) { } /** * Delete all field data for an object. * - * @param $obj_type + * @param $entity_type * The entity type of object, such as 'node' or 'user'. - * @param $object + * @param $entity * The object on which to operate. * @param $fields * An array listing the fields to delete. The keys and values of the * array are field ids. */ -function hook_field_storage_delete($obj_type, $object, $fields) { +function hook_field_storage_delete($entity_type, $entity, $fields) { } /** @@ -1229,17 +1229,17 @@ function hook_field_storage_delete($obj_type, $object, $fields) { * Deleting the current (most recently written) revision is not * allowed as has undefined results. * - * @param $obj_type + * @param $entity_type * The entity type of object, such as 'node' or 'user'. - * @param $object + * @param $entity * The object on which to operate. The revision to delete is * indicated by the object's revision id property, as identified by - * hook_fieldable_info() for $obj_type. + * hook_fieldable_info() for $entity_type. * @param $fields * An array listing the fields to delete. The keys and values of the * array are field ids. */ -function hook_field_storage_delete_revision($obj_type, $object, $fields) { +function hook_field_storage_delete_revision($entity_type, $entity, $fields) { } /** @@ -1297,9 +1297,9 @@ function hook_field_storage_delete_instance($instance) { * subset of fields in a different way than the current storage engine. * Possible use cases include: per-bundle storage, per-combo-field storage... * - * @param $obj_type + * @param $entity_type * The type of objects for which to load fields; e.g. 'node' or 'user'. - * @param $objects + * @param $entities * An array of objects for which to load fields, keyed by object id. * @param $age * FIELD_LOAD_CURRENT to load the most recent revision for all fields, or @@ -1309,11 +1309,11 @@ function hook_field_storage_delete_instance($instance) { * therefore should not be loaded again. The values associated to these keys * are not specified. * @return - * - Loaded field values are added to $objects. Fields with no values should + * - Loaded field values are added to $entities. Fields with no values should * be set as an empty array. * - Loaded field ids are set as keys in $skip_fields. */ -function hook_field_storage_pre_load($obj_type, $objects, $age, &$skip_fields) { +function hook_field_storage_pre_load($entity_type, $entities, $age, &$skip_fields) { } /** @@ -1322,9 +1322,9 @@ function hook_field_storage_pre_load($obj_type, $objects, $age, &$skip_fields) { * This hook allows modules to store data before the Field Storage API, * optionally preventing the field storage module from doing so. * - * @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 object with fields to save. * @param $skip_fields * An array keyed by field ids whose data has already been written and @@ -1333,19 +1333,19 @@ function hook_field_storage_pre_load($obj_type, $objects, $age, &$skip_fields) { * @return * Saved field ids are set set as keys in $skip_fields. */ -function hook_field_storage_pre_insert($obj_type, $object, &$skip_fields) { - if ($obj_type == 'node' && $object->status && _forum_node_check_node_type($object)) { +function hook_field_storage_pre_insert($entity_type, $entity, &$skip_fields) { + if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($object->taxonomy_forums as $language) { + foreach ($entity->taxonomy_forums as $language) { foreach ($language as $delta) { $query->values(array( - 'nid' => $object->nid, - 'title' => $object->title, + 'nid' => $entity->nid, + 'title' => $entity->title, 'tid' => $delta['value'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, 'comment_count' => 0, - 'last_comment_timestamp' => $object->created, + 'last_comment_timestamp' => $entity->created, )); } } @@ -1359,9 +1359,9 @@ function hook_field_storage_pre_insert($obj_type, $object, &$skip_fields) { * This hook allows modules to store data before the Field Storage API, * optionally preventing the field storage module from doing so. * - * @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 object with fields to save. * @param $skip_fields * An array keyed by field ids whose data has already been written and @@ -1370,37 +1370,37 @@ function hook_field_storage_pre_insert($obj_type, $object, &$skip_fields) { * @return * Saved field ids are set set as keys in $skip_fields. */ -function hook_field_storage_pre_update($obj_type, $object, &$skip_fields) { +function hook_field_storage_pre_update($entity_type, $entity, &$skip_fields) { $first_call = &drupal_static(__FUNCTION__, array()); - if ($obj_type == 'node' && $object->status && _forum_node_check_node_type($object)) { + if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) { // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. - if (!isset($first_call[$object->nid])) { - $first_call[$object->nid] = FALSE; - db_delete('forum_index')->condition('nid', $object->nid)->execute(); + if (!isset($first_call[$entity->nid])) { + $first_call[$entity->nid] = FALSE; + db_delete('forum_index')->condition('nid', $entity->nid)->execute(); } // Only save data to the table if the node is published. - if ($object->status) { + if ($entity->status) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($object->taxonomy_forums as $language) { + foreach ($entity->taxonomy_forums as $language) { foreach ($language as $delta) { $query->values(array( - 'nid' => $object->nid, - 'title' => $object->title, + 'nid' => $entity->nid, + 'title' => $entity->title, 'tid' => $delta['value'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, 'comment_count' => 0, - 'last_comment_timestamp' => $object->created, + 'last_comment_timestamp' => $entity->created, )); } } $query->execute(); // The logic for determining last_comment_count is fairly complex, so // call _forum_update_forum_index() too. - _forum_update_forum_index($object->nid); + _forum_update_forum_index($entity->nid); } } } @@ -1592,9 +1592,9 @@ function hook_field_read_instance($instance) { * - "view" * @param $field * The field on which the operation is to be performed. - * @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 * (optional) The object for the operation. * @param $account * (optional) The account to check, if not given use currently logged in user. @@ -1602,5 +1602,5 @@ function hook_field_read_instance($instance) { * TRUE if the operation is allowed; * FALSE if the operation is denied. */ -function hook_field_access($op, $field, $obj_type, $object, $account) { +function hook_field_access($op, $field, $entity_type, $entity, $account) { } diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index f392e1743..661de3649 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -84,12 +84,12 @@ define('FIELD_STORAGE_INSERT', 'insert'); * structures, display, and perform a variety of other functions for * field data connected to individual objects. * - * Field Attach API functions generally take $obj_type and $object + * Field Attach API functions generally take $entity_type and $entity * arguments along with additional function-specific arguments. - * $obj_type is the type of the fieldable entity, such as 'node' or - * 'user', and $object is the object itself. An individual object's + * $entity_type is the type of the fieldable entity, such as 'node' or + * 'user', and $entity is the object itself. An individual object's * bundle, if any, is read from the object's bundle key property - * identified by hook_fieldable_info() for $obj_type. + * identified by hook_fieldable_info() for $entity_type. * * Fieldable types call Field Attach API functions during their own * API calls; for example, node_load() calls field_attach_load(). A @@ -136,10 +136,10 @@ define('FIELD_STORAGE_INSERT', 'insert'); * - delete revision * - view * - prepare translation - * @param $obj_type - * The type of $object; e.g. 'node' or 'user'. - * @param $object - * The fully formed $obj_type object. + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. + * @param $entity + * The fully formed $entity_type object. * @param $a * - The $form in the 'form' operation. * - The value of $view_mode in the 'view' operation. @@ -169,7 +169,7 @@ define('FIELD_STORAGE_INSERT', 'insert'); * as well as non-deleted fields. If unset or FALSE, only * non-deleted fields are operated on. */ -function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options = array()) { +function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) { // Merge default options. $default_options = array( 'default' => FALSE, @@ -180,13 +180,13 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options // Iterate through the object's field instances. $return = array(); - list(, , $bundle) = entity_extract_ids($obj_type, $object); + list(, , $bundle) = entity_extract_ids($entity_type, $entity); if ($options['deleted']) { - $instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted'])); + $instances = field_read_instances(array('object_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted'])); } else { - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); } foreach ($instances as $instance) { @@ -199,8 +199,8 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options $suggested_languages = empty($options['language']) ? NULL : array($options['language']); // Initialize field translations according to the available languages. - foreach (field_multilingual_available_languages($obj_type, $field, $suggested_languages) as $langcode) { - $field_translations[$langcode] = isset($object->{$field_name}[$langcode]) ? $object->{$field_name}[$langcode] : array(); + foreach (field_multilingual_available_languages($entity_type, $field, $suggested_languages) as $langcode) { + $field_translations[$langcode] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); } // Invoke the field hook and collect results. @@ -208,7 +208,7 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options if (function_exists($function)) { // Iterate over all the field translations. foreach ($field_translations as $langcode => $items) { - $result = $function($obj_type, $object, $field, $instance, $langcode, $items, $a, $b); + $result = $function($entity_type, $entity, $field, $instance, $langcode, $items, $a, $b); if (isset($result)) { // For hooks with array results, we merge results together. // For hooks with scalar results, we collect results in an array. @@ -222,8 +222,8 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options // Populate $items back in the field values, but avoid replacing missing // fields with an empty array (those are not equivalent on update). - if ($items !== array() || isset($object->{$field_name}[$langcode])) { - $object->{$field_name}[$langcode] = $items; + if ($items !== array() || isset($entity->{$field_name}[$langcode])) { + $entity->{$field_name}[$langcode] = $items; } } } @@ -242,9 +242,9 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options * - prepare_view * For all other operations, use _field_invoke() / field_invoke_default() * instead. - * @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, keyed by object id. * @param $a * - The $age parameter in the 'load' operation. @@ -274,7 +274,7 @@ function _field_invoke($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options * @return * An array of returned values keyed by object id. */ -function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL, $options = array()) { +function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array()) { // Merge default options. $default_options = array( 'default' => FALSE, @@ -296,15 +296,15 @@ function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL // deleted fields which may have non-unique names. However, objects can only // contain data for a single field for each name, even if that field // is deleted, so we reference field data via the - // $object->$field_name property. - foreach ($objects as $object) { - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + // $entity->$field_name property. + foreach ($entities as $entity) { + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); if ($options['deleted']) { $instances = field_read_field(array('bundle' => $bundle, array('include_deleted' => $options['deleted']))); } else { - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); } foreach ($instances as $instance) { @@ -318,12 +318,12 @@ function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL } // Group the corresponding instances and objects. $grouped_instances[$field_id][$id] = $instance; - $grouped_objects[$field_id][$id] = $objects[$id]; + $grouped_objects[$field_id][$id] = $entities[$id]; // Extract the field values into a separate variable, easily accessed // by hook implementations. $suggested_languages = empty($options['language']) ? NULL : array($options['language']); - foreach (field_multilingual_available_languages($obj_type, $fields[$field_id], $suggested_languages) as $langcode) { - $grouped_items[$field_id][$langcode][$id] = isset($object->{$field_name}[$langcode]) ? $object->{$field_name}[$langcode] : array(); + foreach (field_multilingual_available_languages($entity_type, $fields[$field_id], $suggested_languages) as $langcode) { + $grouped_items[$field_id][$langcode][$id] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array(); } } } @@ -338,7 +338,7 @@ function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL if (function_exists($function)) { // Iterate over all the field translations. foreach ($grouped_items[$field_id] as $langcode => $items) { - $results = $function($obj_type, $grouped_objects[$field_id], $field, $grouped_instances[$field_id], $langcode, $grouped_items[$field_id][$langcode], $a, $b); + $results = $function($entity_type, $grouped_objects[$field_id], $field, $grouped_instances[$field_id], $langcode, $grouped_items[$field_id][$langcode], $a, $b); if (isset($results)) { // Collect results by object. // For hooks with array results, we merge results together. @@ -357,10 +357,10 @@ function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL // Populate field values back in the objects, but avoid replacing missing // fields with an empty array (those are not equivalent on update). - foreach ($grouped_objects[$field_id] as $id => $object) { + foreach ($grouped_objects[$field_id] as $id => $entity) { foreach ($grouped_items[$field_id] as $langcode => $items) { - if ($grouped_items[$field_id][$langcode][$id] !== array() || isset($object->{$field_name}[$langcode])) { - $object->{$field_name}[$langcode] = $grouped_items[$field_id][$langcode][$id]; + if ($grouped_items[$field_id][$langcode][$id] !== array() || isset($entity->{$field_name}[$langcode])) { + $entity->{$field_name}[$langcode] = $grouped_items[$field_id][$langcode][$id]; } } } @@ -378,9 +378,9 @@ function _field_invoke_multiple($op, $obj_type, $objects, &$a = NULL, &$b = NULL * * @see _field_invoke(). */ -function _field_invoke_default($op, $obj_type, $object, &$a = NULL, &$b = NULL, $options = array()) { +function _field_invoke_default($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $options = array()) { $options['default'] = TRUE; - return _field_invoke($op, $obj_type, $object, $a, $b, $options); + return _field_invoke($op, $entity_type, $entity, $a, $b, $options); } /** @@ -392,9 +392,9 @@ function _field_invoke_default($op, $obj_type, $object, &$a = NULL, &$b = NULL, * * @see _field_invoke_multiple(). */ -function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$b = NULL, $options = array()) { +function _field_invoke_multiple_default($op, $entity_type, $entities, &$a = NULL, &$b = NULL, $options = array()) { $options['default'] = TRUE; - return _field_invoke_multiple($op, $obj_type, $objects, $a, $b, $options); + return _field_invoke_multiple($op, $entity_type, $entities, $a, $b, $options); } /** @@ -473,9 +473,9 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$ * ), * @endcode * - * @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 object for which to load form elements, used to initialize * default form values. * @param $form @@ -490,22 +490,22 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$ * parameter. Processing information is added by reference in * $form_state['field']. */ -function field_attach_form($obj_type, $object, &$form, &$form_state, $langcode = NULL) { +function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode = NULL) { // If no language is provided use the default site language. $options = array('language' => field_multilingual_valid_language($langcode)); - $form += (array) _field_invoke_default('form', $obj_type, $object, $form, $form_state, $options); + $form += (array) _field_invoke_default('form', $entity_type, $entity, $form, $form_state, $options); // Add custom weight handling. - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $form['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css'; $form['#pre_render'][] = '_field_extra_weights_pre_render'; - $form['#extra_fields'] = field_extra_fields($obj_type, $bundle); + $form['#extra_fields'] = field_extra_fields($entity_type, $bundle); // Let other modules make changes to the form. // Avoid module_invoke_all() to let parameters be taken by reference. foreach (module_implements('field_attach_form') as $module) { $function = $module . '_field_attach_form'; - $function($obj_type, $object, $form, $form_state, $langcode); + $function($entity_type, $entity, $form, $form_state, $langcode); } } @@ -513,9 +513,9 @@ function field_attach_form($obj_type, $object, &$form, &$form_state, $langcode = * Load all fields for the most current version of each of a set of * objects of a single object type. * - * @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 for which to load fields, keyed by object id. * Each object needs to have its 'bundle', 'id' and (if applicable) * 'revision' keys filled. @@ -534,9 +534,9 @@ function field_attach_form($obj_type, $object, &$form, &$form_state, $langcode = * as well as non-deleted fields. If unset or FALSE, only * non-deleted fields are operated on. * @return - * Loaded field values are added to $objects. + * Loaded field values are added to $entities. */ -function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $options = array()) { +function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $options = array()) { $load_current = $age == FIELD_LOAD_CURRENT; // Merge default options. @@ -545,37 +545,37 @@ function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $opti ); $options += $default_options; - $info = entity_get_info($obj_type); + $info = entity_get_info($entity_type); // Only the most current revision of non-deleted fields for // cacheable fieldable types can be cached. $cache_read = $load_current && $info['cacheable'] && empty($options['deleted']); // In addition, do not write to the cache when loading a single field. $cache_write = $cache_read && !isset($options['field_id']); - if (empty($objects)) { + if (empty($entities)) { return; } // Assume all objects will need to be queried. Objects found in the cache // will be removed from the list. - $queried_objects = $objects; + $queried_objects = $entities; // Fetch available objects from cache, if applicable. if ($cache_read) { // Build the list of cache entries to retrieve. $cids = array(); - foreach ($objects as $id => $object) { - $cids[] = "field:$obj_type:$id"; + foreach ($entities as $id => $entity) { + $cids[] = "field:$entity_type:$id"; } $cache = cache_get_multiple($cids, 'cache_field'); // Put the cached field values back into the objects and remove them from // the list of objects to query. - foreach ($objects as $id => $object) { - $cid = "field:$obj_type:$id"; + foreach ($entities as $id => $entity) { + $cid = "field:$entity_type:$id"; if (isset($cache[$cid])) { unset($queried_objects[$id]); foreach ($cache[$cid]->data as $field_name => $values) { - $object->$field_name = $values; + $entity->$field_name = $values; } } } @@ -594,18 +594,18 @@ function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $opti $skip_fields = array(); foreach (module_implements('field_storage_pre_load') as $module) { $function = $module . '_field_storage_pre_load'; - $function($obj_type, $queried_objects, $age, $skip_fields, $options); + $function($entity_type, $queried_objects, $age, $skip_fields, $options); } // Collect the storage backends used by the remaining fields in the objects. $storages = array(); foreach ($queried_objects as $obj) { - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $obj); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $obj); if ($options['deleted']) { - $instances = field_read_instances(array('object_type' => $obj_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted'])); + $instances = field_read_instances(array('object_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted'])); } else { - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); } foreach ($instances as $instance) { @@ -628,26 +628,26 @@ function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $opti // Invoke hook_field_storage_load() on the relevant storage backends. foreach ($storages as $storage => $fields) { $storage_info = field_info_storage_types($storage); - module_invoke($storage_info['module'], 'field_storage_load', $obj_type, $queried_objects, $age, $fields, $options); + module_invoke($storage_info['module'], 'field_storage_load', $entity_type, $queried_objects, $age, $fields, $options); } // Invoke field-type module's hook_field_load(). - _field_invoke_multiple('load', $obj_type, $queried_objects, $age, $options); + _field_invoke_multiple('load', $entity_type, $queried_objects, $age, $options); // Invoke hook_field_attach_load(): let other modules act on loading the // object. - module_invoke_all('field_attach_load', $obj_type, $queried_objects, $age, $options); + module_invoke_all('field_attach_load', $entity_type, $queried_objects, $age, $options); // Build cache data. if ($cache_write) { - foreach ($queried_objects as $id => $object) { + foreach ($queried_objects as $id => $entity) { $data = array(); - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); - $instances = field_info_instances($obj_type, $bundle); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); + $instances = field_info_instances($entity_type, $bundle); foreach ($instances as $instance) { $data[$instance['field_name']] = $queried_objects[$id]->{$instance['field_name']}; } - $cid = "field:$obj_type:$id"; + $cid = "field:$entity_type:$id"; cache_set($cid, $data, 'cache_field'); } } @@ -661,9 +661,9 @@ function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $opti * Loading different versions of the same objects is not supported, * and should be done by separate calls to the function. * - * @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 for which to load fields, keyed by object id. * Each object needs to have its 'bundle', 'id' and (if applicable) * 'revision' keys filled. @@ -674,11 +674,11 @@ function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT, $opti * may contain data for other fields, for example if they are read * from a cache. * @return - * On return, the objects in $objects are modified by having the + * On return, the objects in $entities are modified by having the * appropriate set of fields added. */ -function field_attach_load_revision($obj_type, $objects, $options = array()) { - return field_attach_load($obj_type, $objects, FIELD_LOAD_REVISION, $options); +function field_attach_load_revision($entity_type, $entities, $options = array()) { + return field_attach_load($entity_type, $entities, FIELD_LOAD_REVISION, $options); } /** @@ -689,27 +689,27 @@ function field_attach_load_revision($obj_type, $objects, $options = array()) { * operations. Use field_attach_form_validate() to validate form * submissions. * - * @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 object with fields to validate. * @throws FieldValidationException * If validation errors are found, a FieldValidationException is thrown. The * 'errors' property contains the array of errors, keyed by field name, * language and delta. */ -function field_attach_validate($obj_type, $object) { +function field_attach_validate($entity_type, $entity) { $errors = array(); // Check generic, field-type-agnostic errors first. - _field_invoke_default('validate', $obj_type, $object, $errors); + _field_invoke_default('validate', $entity_type, $entity, $errors); // Check field-type specific errors. - _field_invoke('validate', $obj_type, $object, $errors); + _field_invoke('validate', $entity_type, $entity, $errors); // Let other modules validate the object. // Avoid module_invoke_all() to let $errors be taken by reference. foreach (module_implements('field_attach_validate') as $module) { $function = $module . '_field_attach_validate'; - $function($obj_type, $object, $errors); + $function($entity_type, $entity, $errors); } if ($errors) { @@ -734,9 +734,9 @@ function field_attach_validate($obj_type, $object) { * on the correct form elements. Fieldable object types should call * this function during their own form validation function. * - * @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 object being submitted. The 'bundle', 'id' and (if applicable) * 'revision' keys should be present. The actual field values will be read * from $form_state['values']. @@ -745,13 +745,13 @@ function field_attach_validate($obj_type, $object) { * @param $form_state * An associative array containing the current state of the form. */ -function field_attach_form_validate($obj_type, $object, $form, &$form_state) { +function field_attach_form_validate($entity_type, $entity, $form, &$form_state) { // Extract field values from submitted values. - _field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state); + _field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state); // Perform field_level validation. try { - field_attach_validate($obj_type, $object); + field_attach_validate($entity_type, $entity); } catch (FieldValidationException $e) { // Pass field-level validation errors back to widgets for accurate error @@ -761,7 +761,7 @@ function field_attach_form_validate($obj_type, $object, $form, &$form_state) { $form_state['field'][$field_name][$langcode]['errors'] = $language_errors; } } - _field_invoke_default('form_errors', $obj_type, $object, $form, $form_state); + _field_invoke_default('form_errors', $entity_type, $entity, $form, $form_state); } } @@ -771,9 +771,9 @@ function field_attach_form_validate($obj_type, $object, $form, &$form_state) { * Currently, this accounts for drag-and-drop reordering of * field values, and filtering of empty values. * - * @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 object being submitted. The 'bundle', 'id' and (if applicable) * 'revision' keys should be present. The actual field values will be read * from $form_state['values']. @@ -782,17 +782,17 @@ function field_attach_form_validate($obj_type, $object, $form, &$form_state) { * @param $form_state * An associative array containing the current state of the form. */ -function field_attach_submit($obj_type, $object, $form, &$form_state) { +function field_attach_submit($entity_type, $entity, $form, &$form_state) { // Extract field values from submitted values. - _field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state); + _field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state); - _field_invoke_default('submit', $obj_type, $object, $form, $form_state); + _field_invoke_default('submit', $entity_type, $entity, $form, $form_state); // Let other modules act on submitting the object. // Avoid module_invoke_all() to let $form_state be taken by reference. foreach (module_implements('field_attach_submit') as $module) { $function = $module . '_field_attach_submit'; - $function($obj_type, $object, $form, $form_state); + $function($entity_type, $entity, $form, $form_state); } } @@ -802,16 +802,16 @@ function field_attach_submit($obj_type, $object, $form, &$form_state) { * We take no specific action here, we just give other * modules the opportunity to act. * - * @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 object with fields to process. */ -function field_attach_presave($obj_type, $object) { - _field_invoke('presave', $obj_type, $object); +function field_attach_presave($entity_type, $entity) { + _field_invoke('presave', $entity_type, $entity); // Let other modules act on presaving the object. - module_invoke_all('field_attach_presave', $obj_type, $object); + module_invoke_all('field_attach_presave', $entity_type, $entity); } /** @@ -820,37 +820,37 @@ function field_attach_presave($obj_type, $object) { * The passed in object must already contain its id and (if applicable) * revision id attributes. * Default values (if any) will be saved for fields not present in the - * $object. + * $entity. * - * @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 object with fields to save. * @return - * Default values (if any) will be added to the $object parameter for fields + * Default values (if any) will be added to the $entity parameter for fields * it leaves unspecified. */ -function field_attach_insert($obj_type, $object) { - _field_invoke_default('insert', $obj_type, $object); - _field_invoke('insert', $obj_type, $object); +function field_attach_insert($entity_type, $entity) { + _field_invoke_default('insert', $entity_type, $entity); + _field_invoke('insert', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); // Let any module insert field data before the storage engine, accumulating // saved fields along the way. $skip_fields = array(); foreach (module_implements('field_storage_pre_insert') as $module) { $function = $module . '_field_storage_pre_insert'; - $function($obj_type, $object, $skip_fields); + $function($entity_type, $entity, $skip_fields); } // Collect the storage backends used by the remaining fields in the objects. $storages = array(); - foreach (field_info_instances($obj_type, $bundle) as $instance) { + foreach (field_info_instances($entity_type, $bundle) as $instance) { $field = field_info_field_by_id($instance['field_id']); $field_id = $field['id']; $field_name = $field['field_name']; - if (!empty($object->$field_name)) { + if (!empty($entity->$field_name)) { // Collect the storage backend if the field has not been written yet. if (!isset($skip_fields[$field_id])) { $storages[$field['storage']['type']][$field_id] = $field_id; @@ -861,49 +861,49 @@ function field_attach_insert($obj_type, $object) { // Field storage backends save any remaining unsaved fields. foreach ($storages as $storage => $fields) { $storage_info = field_info_storage_types($storage); - module_invoke($storage_info['module'], 'field_storage_write', $obj_type, $object, FIELD_STORAGE_INSERT, $fields); + module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_INSERT, $fields); } // Let other modules act on inserting the object. - module_invoke_all('field_attach_insert', $obj_type, $object); + module_invoke_all('field_attach_insert', $entity_type, $entity); if ($cacheable) { - cache_clear_all("field:$obj_type:$id", 'cache_field'); + cache_clear_all("field:$entity_type:$id", 'cache_field'); } } /** * Save field data for an existing object. * - * @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 object with fields to save. */ -function field_attach_update($obj_type, $object) { - _field_invoke('update', $obj_type, $object); +function field_attach_update($entity_type, $entity) { + _field_invoke('update', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); // Let any module update field data before the storage engine, accumulating // saved fields along the way. $skip_fields = array(); foreach (module_implements('field_storage_pre_update') as $module) { $function = $module . '_field_storage_pre_update'; - $function($obj_type, $object, $skip_fields); + $function($entity_type, $entity, $skip_fields); } // Collect the storage backends used by the remaining fields in the objects. $storages = array(); - foreach (field_info_instances($obj_type, $bundle) as $instance) { + foreach (field_info_instances($entity_type, $bundle) as $instance) { $field = field_info_field_by_id($instance['field_id']); $field_id = $field['id']; $field_name = $field['field_name']; - // Leave the field untouched if $object comes with no $field_name property, + // Leave the field untouched if $entity comes with no $field_name property, // but empty the field if it comes as a NULL value or an empty array. // Function property_exists() is slower, so we catch the more frequent // cases where it's an empty array with the faster isset(). - if (isset($object->$field_name) || property_exists($object, $field_name)) { + if (isset($entity->$field_name) || property_exists($entity, $field_name)) { // Collect the storage backend if the field has not been written yet. if (!isset($skip_fields[$field_id])) { $storages[$field['storage']['type']][$field_id] = $field_id; @@ -914,14 +914,14 @@ function field_attach_update($obj_type, $object) { // Field storage backends save any remaining unsaved fields. foreach ($storages as $storage => $fields) { $storage_info = field_info_storage_types($storage); - module_invoke($storage_info['module'], 'field_storage_write', $obj_type, $object, FIELD_STORAGE_UPDATE, $fields); + module_invoke($storage_info['module'], 'field_storage_write', $entity_type, $entity, FIELD_STORAGE_UPDATE, $fields); } // Let other modules act on updating the object. - module_invoke_all('field_attach_update', $obj_type, $object); + module_invoke_all('field_attach_update', $entity_type, $entity); if ($cacheable) { - cache_clear_all("field:$obj_type:$id", 'cache_field'); + cache_clear_all("field:$entity_type:$id", 'cache_field'); } } @@ -929,19 +929,19 @@ function field_attach_update($obj_type, $object) { * Delete field data for an existing object. This deletes all * revisions of field data for the object. * - * @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 object whose field data to delete. */ -function field_attach_delete($obj_type, $object) { - _field_invoke('delete', $obj_type, $object); +function field_attach_delete($entity_type, $entity) { + _field_invoke('delete', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); // Collect the storage backends used by the fields in the objects. $storages = array(); - foreach (field_info_instances($obj_type, $bundle) as $instance) { + foreach (field_info_instances($entity_type, $bundle) as $instance) { $field = field_info_field_by_id($instance['field_id']); $field_id = $field['id']; $storages[$field['storage']['type']][$field_id] = $field_id; @@ -950,14 +950,14 @@ function field_attach_delete($obj_type, $object) { // Field storage backends delete their data. foreach ($storages as $storage => $fields) { $storage_info = field_info_storage_types($storage); - module_invoke($storage_info['module'], 'field_storage_delete', $obj_type, $object, $fields); + module_invoke($storage_info['module'], 'field_storage_delete', $entity_type, $entity, $fields); } // Let other modules act on deleting the object. - module_invoke_all('field_attach_delete', $obj_type, $object); + module_invoke_all('field_attach_delete', $entity_type, $entity); if ($cacheable) { - cache_clear_all("field:$obj_type:$id", 'cache_field'); + cache_clear_all("field:$entity_type:$id", 'cache_field'); } } @@ -965,19 +965,19 @@ function field_attach_delete($obj_type, $object) { * Delete field data for a single revision of an existing object. The * passed object must have a revision id attribute. * - * @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 object with fields to save. */ -function field_attach_delete_revision($obj_type, $object) { - _field_invoke('delete_revision', $obj_type, $object); +function field_attach_delete_revision($entity_type, $entity) { + _field_invoke('delete_revision', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); // Collect the storage backends used by the fields in the objects. $storages = array(); - foreach (field_info_instances($obj_type, $bundle) as $instance) { + foreach (field_info_instances($entity_type, $bundle) as $instance) { $field = field_info_field_by_id($instance['field_id']); $field_id = $field['id']; $storages[$field['storage']['type']][$field_id] = $field_id; @@ -986,11 +986,11 @@ function field_attach_delete_revision($obj_type, $object) { // Field storage backends delete their data. foreach ($storages as $storage => $fields) { $storage_info = field_info_storage_types($storage); - module_invoke($storage_info['module'], 'field_storage_delete_revision', $obj_type, $object, $fields); + module_invoke($storage_info['module'], 'field_storage_delete_revision', $entity_type, $entity, $fields); } // Let other modules act on deleting the revision. - module_invoke_all('field_attach_delete_revision', $obj_type, $object); + module_invoke_all('field_attach_delete_revision', $entity_type, $entity); } /** @@ -1131,34 +1131,34 @@ function field_attach_query_revisions($field_id, $conditions, $options = array() * therefore accepts an array of objects to allow query optimisation when * displaying lists of objects. * - * @param $obj_type - * The type of $objects; e.g. 'node' or 'user'. - * @param $objects + * @param $entity_type + * The type of $entities; e.g. 'node' or 'user'. + * @param $entities * An array of objects, keyed by object id. * @param $view_mode * View mode, e.g. 'full', 'teaser'... */ -function field_attach_prepare_view($obj_type, $objects, $view_mode = 'full') { +function field_attach_prepare_view($entity_type, $entities, $view_mode = 'full') { // To ensure hooks are only run once per entity, only process items without // the _field_view_prepared flag. // @todo: resolve this more generally for both entity and field level hooks. $prepare = array(); - foreach ($objects as $id => $object) { - if (empty($object->_field_view_prepared)) { + foreach ($entities as $id => $entity) { + if (empty($entity->_field_view_prepared)) { // Add this entity to the items to be prepared. - $prepare[$id] = $object; + $prepare[$id] = $entity; // Mark this item as prepared. - $object->_field_view_prepared = TRUE; + $entity->_field_view_prepared = TRUE; } } // First let the field types do their preparation. - _field_invoke_multiple('prepare_view', $obj_type, $prepare); + _field_invoke_multiple('prepare_view', $entity_type, $prepare); // Then let the formatters do their own specific massaging. // field_default_prepare_view() takes care of dispatching to the correct // formatters according to the display settings for the view mode. - _field_invoke_multiple_default('prepare_view', $obj_type, $prepare, $view_mode); + _field_invoke_multiple_default('prepare_view', $entity_type, $prepare, $view_mode); } /** @@ -1191,9 +1191,9 @@ function field_attach_prepare_view($obj_type, $objects, $view_mode = 'full') { * ); * @endcode * - * @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 object with fields to render. * @param $view_mode * View mode, e.g. 'full', 'teaser'... @@ -1203,25 +1203,25 @@ function field_attach_prepare_view($obj_type, $objects, $view_mode = 'full') { * @return * A renderable array for the field values. */ -function field_attach_view($obj_type, $object, $view_mode = 'full', $langcode = NULL) { +function field_attach_view($entity_type, $entity, $view_mode = 'full', $langcode = NULL) { // Invoke field_default_view(). If no language is provided, use the current // UI language. $options = array('language' => field_multilingual_valid_language($langcode, FALSE)); $null = NULL; - $output = _field_invoke_default('view', $obj_type, $object, $view_mode, $null, $options); + $output = _field_invoke_default('view', $entity_type, $entity, $view_mode, $null, $options); // Add custom weight handling. - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $output['#pre_render'][] = '_field_extra_weights_pre_render'; - $output['#extra_fields'] = field_extra_fields($obj_type, $bundle); + $output['#extra_fields'] = field_extra_fields($entity_type, $bundle); // Include CSS styles. $output['#attached']['css'][] = drupal_get_path('module', 'field') . '/theme/field.css'; // Let other modules alter the renderable array. $context = array( - 'obj_type' => $obj_type, - 'object' => $object, + 'obj_type' => $entity_type, + 'object' => $entity, 'view_mode' => $view_mode, 'langcode' => $langcode, ); @@ -1230,7 +1230,7 @@ function field_attach_view($obj_type, $object, $view_mode = 'full', $langcode = // Reset the _field_view_prepared flag set in field_attach_prepare_view(), // in case the same object is displayed with different settings later in // the request. - unset($object->_field_view_prepared); + unset($entity->_field_view_prepared); return $output; } @@ -1243,9 +1243,9 @@ function field_attach_view($obj_type, $object, $view_mode = 'full', $langcode = * translatable fields the language currently chosen for display will be * selected. * - * @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 object with fields to render. * @param $element * The structured array containing the values ready for rendering. @@ -1253,21 +1253,21 @@ function field_attach_view($obj_type, $object, $view_mode = 'full', $langcode = * The variables array is passed by reference and will be populated with field * values. */ -function field_attach_preprocess($obj_type, $object, $element, &$variables) { - list(, , $bundle) = entity_extract_ids($obj_type, $object); +function field_attach_preprocess($entity_type, $entity, $element, &$variables) { + list(, , $bundle) = entity_extract_ids($entity_type, $entity); - foreach (field_info_instances($obj_type, $bundle) as $instance) { + foreach (field_info_instances($entity_type, $bundle) as $instance) { $field_name = $instance['field_name']; if (isset($element[$field_name]['#language'])) { $langcode = $element[$field_name]['#language']; - $variables[$field_name] = isset($object->{$field_name}[$langcode]) ? $object->{$field_name}[$langcode] : NULL; + $variables[$field_name] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : NULL; } } // Let other modules make changes to the $variables array. $context = array( - 'obj_type' => $obj_type, - 'object' => $object, + 'obj_type' => $entity_type, + 'object' => $entity, 'element' => $element, ); drupal_alter('field_attach_preprocess', $variables, $context); @@ -1299,33 +1299,33 @@ function field_attach_prepare_translation($node) { * The default SQL-based storage doesn't need to do anything about it, but * others might. * - * @param $obj_type + * @param $entity_type * The object type to which the bundle is bound. * @param $bundle * The name of the newly created bundle. */ -function field_attach_create_bundle($obj_type, $bundle) { +function field_attach_create_bundle($entity_type, $bundle) { // Clear the cache. field_cache_clear(); // Let other modules act on creating the bundle. - module_invoke_all('field_attach_create_bundle', $obj_type, $bundle); + module_invoke_all('field_attach_create_bundle', $entity_type, $bundle); } /** * Notify field.module that a bundle was renamed. * - * @param $obj_type + * @param $entity_type * The object type to which the bundle is bound. * @param $bundle_old * The previous name of the bundle. * @param $bundle_new * The new name of the bundle. */ -function field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { +function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { db_update('field_config_instance') ->fields(array('bundle' => $bundle_new)) - ->condition('object_type', $obj_type) + ->condition('object_type', $entity_type) ->condition('bundle', $bundle_old) ->execute(); @@ -1333,7 +1333,7 @@ function field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { field_cache_clear(); // Let other modules act on renaming the bundle. - module_invoke_all('field_attach_rename_bundle', $obj_type, $bundle_old, $bundle_new); + module_invoke_all('field_attach_rename_bundle', $entity_type, $bundle_old, $bundle_new); } /** @@ -1346,14 +1346,14 @@ function field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { * (particularly since for some field types, the deletion is more than just a * simple DELETE query). * - * @param $obj_type + * @param $entity_type * The object type to which the bundle is bound. * @param $bundle * The bundle to delete. */ -function field_attach_delete_bundle($obj_type, $bundle) { +function field_attach_delete_bundle($entity_type, $bundle) { // First, delete the instances themseves. - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); foreach ($instances as $instance) { field_delete_instance($instance); } @@ -1362,7 +1362,7 @@ function field_attach_delete_bundle($obj_type, $bundle) { field_cache_clear(); // Let other modules act on deleting the bundle. - module_invoke_all('field_attach_delete_bundle', $obj_type, $bundle, $instances); + module_invoke_all('field_attach_delete_bundle', $entity_type, $bundle, $instances); } diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index 1cc95217e..cb2022dd4 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -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); } } diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc index fc21945a5..6cdd160aa 100644 --- a/modules/field/field.default.inc +++ b/modules/field/field.default.inc @@ -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; } diff --git a/modules/field/field.form.inc b/modules/field/field.form.inc index 88dd71bdf..6b7c1ca13 100644 --- a/modules/field/field.form.inc +++ b/modules/field/field.form.inc @@ -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]; diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc index d4837cc96..b0358f0ad 100644 --- a/modules/field/field.info.inc +++ b/modules/field/field.info.inc @@ -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]; } } diff --git a/modules/field/field.module b/modules/field/field.module index 9ad7252a1..374a83231 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -274,9 +274,9 @@ function field_associate_fields($module) { /** * Helper function to get the default value for a field on an object. * - * @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 object for the operation. * @param $field * The field structure. @@ -285,12 +285,12 @@ function field_associate_fields($module) { * @param $langcode * The field language to fill-in with the default value. */ -function field_get_default_value($obj_type, $object, $field, $instance, $langcode = NULL) { +function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) { $items = array(); if (!empty($instance['default_value_function'])) { $function = $instance['default_value_function']; if (function_exists($function)) { - $items = $function($obj_type, $object, $field, $instance, $langcode); + $items = $function($entity_type, $entity, $field, $instance, $langcode); } } elseif (!empty($instance['default_value'])) { @@ -367,14 +367,14 @@ function _field_sort_items_value_helper($a, $b) { /** * Registry of pseudo-field components in a given bundle. * - * @param $obj_type - * The type of $object; e.g. 'node' or 'user'. + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. * @param $bundle * The bundle name. * @return * The array of pseudo-field elements in the bundle. */ -function field_extra_fields($obj_type, $bundle) { +function field_extra_fields($entity_type, $bundle) { $info = &drupal_static(__FUNCTION__, array()); if (empty($info)) { @@ -384,25 +384,25 @@ function field_extra_fields($obj_type, $bundle) { // Add saved weights. The array is keyed by object type, bundle and // element name. $extra_weights = variable_get('field_extra_weights', array()); - foreach ($extra_weights as $obj_type_name => $bundles) { + foreach ($extra_weights as $entity_type_name => $bundles) { foreach ($bundles as $bundle_name => $weights) { foreach ($weights as $key => $value) { - if (isset($info[$obj_type_name][$bundle_name][$key])) { - $info[$obj_type_name][$bundle_name][$key]['weight'] = $value; + if (isset($info[$entity_type_name][$bundle_name][$key])) { + $info[$entity_type_name][$bundle_name][$key]['weight'] = $value; } } } } } - return isset($info[$obj_type][$bundle]) ? $info[$obj_type][$bundle]: array(); + return isset($info[$entity_type][$bundle]) ? $info[$entity_type][$bundle]: array(); } /** * Retrieve the user-defined weight for a 'pseudo-field' component. * - * @param $obj_type - * The type of $object; e.g. 'node' or 'user'. + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. * @param $bundle * The bundle name. * @param $pseudo_field @@ -411,8 +411,8 @@ function field_extra_fields($obj_type, $bundle) { * The weight for the 'pseudo-field', respecting the user settings stored by * field.module. */ -function field_extra_field_weight($obj_type, $bundle, $pseudo_field) { - $extra = field_extra_fields($obj_type, $bundle); +function field_extra_field_weight($entity_type, $bundle, $pseudo_field) { + $extra = field_extra_fields($entity_type, $bundle); if (isset($extra[$pseudo_field])) { return $extra[$pseudo_field]['weight']; } @@ -499,17 +499,17 @@ function _field_filter_xss_display_allowed_tags() { * It will have been passed through the necessary check_plain() or check_markup() * functions as necessary. */ -function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, $formatter_settings = array()) { +function field_format($entity_type, $entity, $field, $item, $formatter_type = NULL, $formatter_settings = array()) { if (!is_array($field)) { $field = field_info_field($field); } - if (field_access('view', $field, $obj_type, $object)) { + if (field_access('view', $field, $entity_type, $entity)) { $field_type = field_info_field_types($field['type']); - // We need $field, $instance, $obj_type, $object to be able to display a value... - list(, , $bundle) = entity_extract_ids($obj_type, $object); - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); + // We need $field, $instance, $entity_type, $entity to be able to display a value... + list(, , $bundle) = entity_extract_ids($entity_type, $entity); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); $display = array( 'type' => $formatter_type ? $formatter_type : $field_type['default_formatter'], @@ -523,12 +523,12 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, $element = array( '#theme' => $theme, '#field_name' => $field['field_name'], - '#object_type' => $obj_type, + '#object_type' => $entity_type, '#bundle' => $bundle, '#formatter' => $display['type'], '#settings' => $display['settings'], - '#object' => $object, - '#object_type' => $obj_type, + '#object' => $entity, + '#object_type' => $entity_type, '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL, ); @@ -539,7 +539,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, $items = array($item); $function = $field['module'] . '_field_sanitize'; if (function_exists($function)) { - $function($obj_type, $object, $field, $instance, $items); + $function($entity_type, $entity, $field, $instance, $items); } $element['#item'] = $items[0]; @@ -549,7 +549,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, $items = $item; $function = $field['module'] . '_field_sanitize'; if (function_exists($function)) { - $function($obj_type, $object, $field, $instance, $items); + $function($entity_type, $entity, $field, $instance, $items); } foreach ($items as $delta => $item) { @@ -580,9 +580,9 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, * The function takes care of invoking the prepare_view steps. It also respects * field access permissions. * - * @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 object containing the field to display. Must at least contain the id * key and the field data to display. * @param $field_name @@ -616,7 +616,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_type = NULL, * @return * A renderable array for the field value. */ -function field_view_field($obj_type, $object, $field_name, $display = array(), $langcode = NULL) { +function field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) { $output = array(); if ($field = field_info_field($field_name)) { @@ -627,8 +627,8 @@ function field_view_field($obj_type, $object, $field_name, $display = array(), $ else { // When using a view mode, make sure we have settings for it, or fall // back to the 'full' view mode. - list(, , $bundle) = entity_extract_ids($obj_type, $object); - $instance = field_info_instance($obj_type, $field_name, $bundle); + list(, , $bundle) = entity_extract_ids($entity_type, $entity); + $instance = field_info_instance($entity_type, $field_name, $bundle); if (!isset($instance['display'][$display])) { $display = 'full'; } @@ -638,20 +638,20 @@ function field_view_field($obj_type, $object, $field_name, $display = array(), $ // 'single field' mode, to reuse the language fallback logic. $options = array('field_name' => $field_name, 'language' => field_multilingual_valid_language($langcode, FALSE)); $null = NULL; - list($id) = entity_extract_ids($obj_type, $object); + list($id) = entity_extract_ids($entity_type, $entity); // First let the field types do their preparation. - _field_invoke_multiple('prepare_view', $obj_type, array($id => $object), $display, $null, $options); + _field_invoke_multiple('prepare_view', $entity_type, array($id => $entity), $display, $null, $options); // Then let the formatters do their own specific massaging. - _field_invoke_multiple_default('prepare_view', $obj_type, array($id => $object), $display, $null, $options); + _field_invoke_multiple_default('prepare_view', $entity_type, array($id => $entity), $display, $null, $options); // Build the renderable array. - $result = _field_invoke_default('view', $obj_type, $object, $display, $null, $options); + $result = _field_invoke_default('view', $entity_type, $entity, $display, $null, $options); // Invoke hook_field_attach_view_alter() to tet other modules alter the // renderable array, as in a full field_attach_view() execution. $context = array( - 'obj_type' => $obj_type, - 'object' => $object, + 'obj_type' => $entity_type, + 'object' => $entity, 'view_mode' => '_custom', 'langcode' => $langcode, ); @@ -688,9 +688,9 @@ function field_has_data($field) { * - "view" * @param $field * The field on which the operation is to be performed. - * @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 * (optional) The object for the operation. * @param $account * (optional) The account to check, if not given use currently logged in user. @@ -698,7 +698,7 @@ function field_has_data($field) { * TRUE if the operation is allowed; * FALSE if the operation is denied. */ -function field_access($op, $field, $obj_type, $object = NULL, $account = NULL) { +function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) { global $user; if (!isset($account)) { @@ -707,7 +707,7 @@ function field_access($op, $field, $obj_type, $object = NULL, $account = NULL) { foreach (module_implements('field_access') as $module) { $function = $module . '_field_access'; - $access = $function($op, $field, $obj_type, $object, $account); + $access = $function($op, $field, $entity_type, $entity, $account); if ($access === FALSE) { return FALSE; } @@ -718,20 +718,20 @@ function field_access($op, $field, $obj_type, $object = NULL, $account = NULL) { /** * Helper function to extract the bundle name of from a bundle object. * - * @param $obj_type - * The type of $object; e.g. 'node' or 'user'. + * @param $entity_type + * The type of $entity; e.g. 'node' or 'user'. * @param $bundle * The bundle object (or string if bundles for this object type do not exist * as standalone objects). * @return * The bundle name. */ -function field_extract_bundle($obj_type, $bundle) { +function field_extract_bundle($entity_type, $bundle) { if (is_string($bundle)) { return $bundle; } - $info = entity_get_info($obj_type); + $info = entity_get_info($entity_type); if (is_object($bundle) && isset($info['bundle keys']['bundle']) && isset($bundle->{$info['bundle keys']['bundle']})) { return $bundle->{$info['bundle keys']['bundle']}; } diff --git a/modules/field/field.multilingual.inc b/modules/field/field.multilingual.inc index bbe3a75d1..1f0f587eb 100644 --- a/modules/field/field.multilingual.inc +++ b/modules/field/field.multilingual.inc @@ -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]); diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module index 65ceb5228..46a00e8d9 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -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') { diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.test b/modules/field/modules/field_sql_storage/field_sql_storage.test index ceb5eeb64..32125ac10 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.test +++ b/modules/field/modules/field_sql_storage/field_sql_storage.test @@ -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); diff --git a/modules/field/modules/list/list.module b/modules/field/modules/list/list.module index 7e9724a94..5dc5cb181 100644 --- a/modules/field/modules/list/list.module +++ b/modules/field/modules/list/list.module @@ -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']) { diff --git a/modules/field/modules/number/number.module b/modules/field/modules/number/number.module index 13d57f9d2..812789d4e 100644 --- a/modules/field/modules/number/number.module +++ b/modules/field/modules/number/number.module @@ -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') { // Let PHP round the value to ensure consistent behavior across storage // backends. @@ -255,7 +255,7 @@ function number_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function number_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) { +function number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); $settings = $display['settings']; diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module index a3389e9d1..9f8a5c6d0 100644 --- a/modules/field/modules/text/text.module +++ b/modules/field/modules/text/text.module @@ -167,7 +167,7 @@ function text_field_instance_settings_form($field, $instance) { * - 'text_value_max_length': The value exceeds the maximum length. * - 'text_summary_max_length': The summary exceeds the maximum length. */ -function text_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) { +function text_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { foreach ($items as $delta => $item) { // @todo Length is counted separately for summary and value, so the maximum // length can be exceeded very easily. @@ -201,8 +201,8 @@ function text_field_validate($obj_type, $object, $field, $instance, $langcode, $ * separately. * @see text_field_formatter_view(). */ -function text_field_load($obj_type, $objects, $field, $instances, $langcode, &$items) { - foreach ($objects as $id => $object) { +function text_field_load($entity_type, $entities, $field, $instances, $langcode, &$items) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Only process items with a cacheable format, the rest will be handled // by formatters if needed. @@ -264,7 +264,7 @@ function text_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function text_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) { +function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 2109748f3..c65a9b8e6 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -2731,26 +2731,26 @@ class FieldTranslationsTestCase extends FieldTestCase { // Prepare the field translations. field_test_entity_info_translatable('test_entity', TRUE); $eid = $evid = 1; - $obj_type = 'test_entity'; - $object = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']); + $entity_type = 'test_entity'; + $entity = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']); $field_translations = array(); - $available_languages = field_multilingual_available_languages($obj_type, $this->field); + $available_languages = field_multilingual_available_languages($entity_type, $this->field); $this->assertTrue(count($available_languages) > 1, t('Field is translatable.')); foreach ($available_languages as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']); } // Save and reload the field translations. - $object->{$this->field_name} = $field_translations; - field_attach_insert($obj_type, $object); - unset($object->{$this->field_name}); - field_attach_load($obj_type, array($eid => $object)); + $entity->{$this->field_name} = $field_translations; + field_attach_insert($entity_type, $entity); + unset($entity->{$this->field_name}); + field_attach_load($entity_type, array($eid => $entity)); // Check if the correct values were saved/loaded. foreach ($field_translations as $langcode => $items) { $result = TRUE; foreach ($items as $delta => $item) { - $result = $result && $item['value'] == $object->{$this->field_name}[$langcode][$delta]['value']; + $result = $result && $item['value'] == $entity->{$this->field_name}[$langcode][$delta]['value']; } $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $langcode))); } @@ -2779,20 +2779,20 @@ class FieldBulkDeleteTestCase extends FieldTestCase { * same fieldable type which contains the data for the field name * (if given). * - * @param $obj_type - * The entity type of $objects. - * @param $objects - * An array of objects of type $obj_type. + * @param $entity_type + * The entity type of $entities. + * @param $entities + * An array of objects of type $entity_type. * @param $field_name * Optional; a field name whose data should be copied from - * $objects into the returned stub objects. + * $entities into the returned stub objects. * @return - * An array of stub objects corresponding to $objects. + * An array of stub objects corresponding to $entities. */ - function _generateStubObjects($obj_type, $objects, $field_name = NULL) { + function _generateStubObjects($entity_type, $entities, $field_name = NULL) { $stubs = array(); - foreach ($objects as $obj) { - $stub = entity_create_stub_entity($obj_type, entity_extract_ids($obj_type, $obj)); + foreach ($entities as $obj) { + $stub = entity_create_stub_entity($entity_type, entity_extract_ids($entity_type, $obj)); if (isset($field_name)) { $stub->{$field_name} = $obj->{$field_name}; } diff --git a/modules/field/tests/field_test.entity.inc b/modules/field/tests/field_test.entity.inc index 0a15bccb6..71810eb86 100644 --- a/modules/field/tests/field_test.entity.inc +++ b/modules/field/tests/field_test.entity.inc @@ -54,12 +54,12 @@ function field_test_entity_info() { */ function field_test_entity_info_alter(&$entity_info) { // Enable/disable field_test as a translation handler. - foreach (field_test_entity_info_translatable() as $obj_type => $translatable) { - $entity_info[$obj_type]['translation']['field_test'] = $translatable; + foreach (field_test_entity_info_translatable() as $entity_type => $translatable) { + $entity_info[$entity_type]['translation']['field_test'] = $translatable; } // Disable locale as a translation handler. - foreach ($entity_info as $obj_type => $info) { - $entity_info[$obj_type]['translation']['locale'] = FALSE; + foreach ($entity_info as $entity_type => $info) { + $entity_info[$entity_type]['translation']['locale'] = FALSE; } } diff --git a/modules/field/tests/field_test.field.inc b/modules/field/tests/field_test.field.inc index 8793e22d2..1213d4d4d 100644 --- a/modules/field/tests/field_test.field.inc +++ b/modules/field/tests/field_test.field.inc @@ -59,7 +59,7 @@ function field_test_field_update_forbid($field, $prior_field, $has_data) { /** * Implements hook_field_load(). */ -function field_test_field_load($obj_type, $objects, $field, $instances, $langcode, &$items, $age) { +function field_test_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { foreach ($items as $id => $item) { // To keep the test non-intrusive, only act for instances with the // test_hook_field_load setting explicitly set to TRUE. @@ -80,7 +80,7 @@ function field_test_field_load($obj_type, $objects, $field, $instances, $langcod * Possible error codes: * - 'field_test_invalid': The value is invalid. */ -function field_test_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) { +function field_test_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { foreach ($items as $delta => $item) { if ($item['value'] == -1) { $errors[$field['field_name']][$langcode][$delta][] = array( @@ -261,7 +261,7 @@ function field_test_field_formatter_info() { /** * Implements hook_field_formatter_prepare_view(). */ -function field_test_field_formatter_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $displays) { +function field_test_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { foreach ($items as $id => $item) { // To keep the test non-intrusive, only act on the // 'field_test_needs_additional_data' formatter. @@ -279,7 +279,7 @@ function field_test_field_formatter_prepare_view($obj_type, $objects, $field, $i /** * Implements hook_field_formatter_view(). */ -function field_test_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) { +function field_test_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); $settings = $display['settings']; @@ -311,14 +311,14 @@ function field_test_field_formatter_view($object_type, $object, $field, $instanc /** * Sample 'default value' callback. */ -function field_test_default_value($obj_type, $object, $field, $instance) { +function field_test_default_value($entity_type, $entity, $field, $instance) { return array(array('value' => 99)); } /** * Implements hook_field_access(). */ -function field_test_field_access($op, $field, $obj_type, $object, $account) { +function field_test_field_access($op, $field, $entity_type, $entity, $account) { if ($field['field_name'] == "field_no_{$op}_access") { return FALSE; } diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module index 5c8689c2c..7d0b8366d 100644 --- a/modules/field/tests/field_test.module +++ b/modules/field/tests/field_test.module @@ -68,8 +68,8 @@ function field_test_menu() { * * This simulates a field operation callback to be invoked by _field_invoke(). */ -function field_test_field_test_op($obj_type, $object, $field, $instance, $langcode, &$items) { - return array($langcode => md5(serialize(array($obj_type, $object, $field['field_name'], $langcode, $items)))); +function field_test_field_test_op($entity_type, $entity, $field, $instance, $langcode, &$items) { + return array($langcode => md5(serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items)))); } /** @@ -78,10 +78,10 @@ function field_test_field_test_op($obj_type, $object, $field, $instance, $langco * This simulates a multiple field operation callback to be invoked by * _field_invoke_multiple(). */ -function field_test_field_test_op_multiple($obj_type, $objects, $field, $instances, $langcode, &$items) { +function field_test_field_test_op_multiple($entity_type, $entities, $field, $instances, $langcode, &$items) { $result = array(); - foreach ($objects as $id => $object) { - $result[$id] = array($langcode => md5(serialize(array($obj_type, $object, $field['field_name'], $langcode, $items[$id])))); + foreach ($entities as $id => $entity) { + $result[$id] = array($langcode => md5(serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items[$id])))); } return $result; } @@ -89,7 +89,7 @@ function field_test_field_test_op_multiple($obj_type, $objects, $field, $instanc /** * Implements hook_field_languages(). */ -function field_test_field_languages($obj_type, $field, &$languages) { +function field_test_field_languages($entity_type, $field, &$languages) { if ($field['settings']['test_hook_in']) { // Add an unavailable language. $languages[] = 'xx'; @@ -101,10 +101,10 @@ function field_test_field_languages($obj_type, $field, &$languages) { /** * Helper function to enable entity translations. */ -function field_test_entity_info_translatable($obj_type = NULL, $translatable = NULL) { +function field_test_entity_info_translatable($entity_type = NULL, $translatable = NULL) { $stored_value = &drupal_static(__FUNCTION__, array()); - if (isset($obj_type)) { - $stored_value[$obj_type] = $translatable; + if (isset($entity_type)) { + $stored_value[$entity_type] = $translatable; entity_info_cache_clear(); } return $stored_value; @@ -175,7 +175,7 @@ function field_test_field_create_field($field) { /** * Memorize calls to hook_field_insert(). */ -function field_test_field_insert($obj_type, $object, $field, $instance, $items) { +function field_test_field_insert($entity_type, $entity, $field, $instance, $items) { $args = func_get_args(); field_test_memorize(__FUNCTION__, $args); } @@ -183,7 +183,7 @@ function field_test_field_insert($obj_type, $object, $field, $instance, $items) /** * Memorize calls to hook_field_update(). */ -function field_test_field_update($obj_type, $object, $field, $instance, $items) { +function field_test_field_update($entity_type, $entity, $field, $instance, $items) { $args = func_get_args(); field_test_memorize(__FUNCTION__, $args); } @@ -191,7 +191,7 @@ function field_test_field_update($obj_type, $object, $field, $instance, $items) /** * Memorize calls to hook_field_delete(). */ -function field_test_field_delete($obj_type, $object, $field, $instance, $items) { +function field_test_field_delete($entity_type, $entity, $field, $instance, $items) { $args = func_get_args(); field_test_memorize(__FUNCTION__, $args); } diff --git a/modules/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc index e85c832cf..1008009d0 100644 --- a/modules/field/tests/field_test.storage.inc +++ b/modules/field/tests/field_test.storage.inc @@ -81,7 +81,7 @@ function _field_test_storage_data($data = NULL) { /** * Implements hook_field_storage_load(). */ -function field_test_field_storage_load($obj_type, $objects, $age, $fields, $options) { +function field_test_field_storage_load($entity_type, $entities, $age, $fields, $options) { $data = _field_test_storage_data(); $load_current = $age == FIELD_LOAD_CURRENT; @@ -93,9 +93,9 @@ function field_test_field_storage_load($obj_type, $objects, $age, $fields, $opti $sub_table = $load_current ? 'current' : 'revisions'; $delta_count = array(); foreach ($field_data[$sub_table] as $row) { - if ($row->type == $obj_type && (!$row->deleted || $options['deleted'])) { + if ($row->type == $entity_type && (!$row->deleted || $options['deleted'])) { if (($load_current && in_array($row->entity_id, $ids)) || (!$load_current && in_array($row->revision_id, $ids))) { - if (in_array($row->language, field_multilingual_available_languages($obj_type, $field))) { + if (in_array($row->language, field_multilingual_available_languages($entity_type, $field))) { if (!isset($delta_count[$row->entity_id][$row->language])) { $delta_count[$row->entity_id][$row->language] = 0; } @@ -104,7 +104,7 @@ function field_test_field_storage_load($obj_type, $objects, $age, $fields, $opti foreach ($field['columns'] as $column => $attributes) { $item[$column] = $row->{$column}; } - $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]++; } } @@ -117,33 +117,33 @@ function field_test_field_storage_load($obj_type, $objects, $age, $fields, $opti /** * Implements hook_field_storage_write(). */ -function field_test_field_storage_write($obj_type, $object, $op, $fields) { +function field_test_field_storage_write($entity_type, $entity, $op, $fields) { $data = _field_test_storage_data(); - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); foreach ($fields as $field_id) { $field = field_info_field_by_id($field_id); $field_name = $field['field_name']; $field_data = &$data[$field_id]; - $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) { foreach ($field_data['current'] as $key => $row) { - if ($row->type == $obj_type && $row->entity_id == $id && in_array($row->language, $languages)) { + if ($row->type == $entity_type && $row->entity_id == $id && in_array($row->language, $languages)) { unset($field_data['current'][$key]); } } if (isset($vid)) { foreach ($field_data['revisions'] as $key => $row) { - if ($row->type == $obj_type && $row->revision_id == $vid) { + if ($row->type == $entity_type && $row->revision_id == $vid) { unset($field_data['revisions'][$key]); } } @@ -152,12 +152,12 @@ function field_test_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) { $row = (object) array( 'field_id' => $field_id, - 'type' => $obj_type, + 'type' => $entity_type, 'entity_id' => $id, 'revision_id' => $vid, 'bundle' => $bundle, @@ -187,15 +187,15 @@ function field_test_field_storage_write($obj_type, $object, $op, $fields) { /** * Implements hook_field_storage_delete(). */ -function field_test_field_storage_delete($obj_type, $object, $fields) { - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); +function field_test_field_storage_delete($entity_type, $entity, $fields) { + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Note: reusing field_test_storage_purge(), like field_sql_storage.module // does, is highly inefficient in our case... foreach (field_info_instances($bundle) as $instance) { if (isset($fields[$instance['field_id']])) { $field = field_info_field_by_id($instance['field_id']); - field_test_field_storage_purge($obj_type, $object, $field, $instance); + field_test_field_storage_purge($entity_type, $entity, $field, $instance); } } } @@ -203,15 +203,15 @@ function field_test_field_storage_delete($obj_type, $object, $fields) { /** * Implements hook_field_storage_purge(). */ -function field_test_field_storage_purge($obj_type, $object, $field, $instance) { +function field_test_field_storage_purge($entity_type, $entity, $field, $instance) { $data = _field_test_storage_data(); - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); $field_data = &$data[$field['id']]; foreach (array('current', 'revisions') as $sub_table) { foreach ($field_data[$sub_table] as $key => $row) { - if ($row->type == $obj_type && $row->entity_id == $id) { + if ($row->type == $entity_type && $row->entity_id == $id) { unset($field_data[$sub_table][$key]); } } @@ -223,15 +223,15 @@ function field_test_field_storage_purge($obj_type, $object, $field, $instance) { /** * Implements hook_field_storage_delete_revision(). */ -function field_test_field_storage_delete_revision($obj_type, $object, $fields) { +function field_test_field_storage_delete_revision($entity_type, $entity, $fields) { $data = _field_test_storage_data(); - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); foreach ($fields as $field_id) { $field_data = &$data[$field_id]; foreach (array('current', 'revisions') as $sub_table) { foreach ($field_data[$sub_table] as $key => $row) { - if ($row->type == $obj_type && $row->entity_id == $id && $row->revision_id == $vid) { + if ($row->type == $entity_type && $row->entity_id == $id && $row->revision_id == $vid) { unset($field_data[$sub_table][$key]); } } diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index c02690392..9d4cb4647 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -15,14 +15,14 @@ function field_ui_fields_list() { $bundles = field_info_bundles(); $header = array(t('Field name'), t('Field type'), t('Used in')); $rows = array(); - foreach ($instances as $obj_type => $type_bundles) { + foreach ($instances as $entity_type => $type_bundles) { foreach ($type_bundles as $bundle => $bundle_instances) { foreach ($bundle_instances as $field_name => $instance) { $field = field_info_field($field_name); - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); $rows[$field_name]['data'][0] = $field['locked'] ? t('@field_name (Locked)', array('@field_name' => $field_name)) : $field_name; $rows[$field_name]['data'][1] = t($field_types[$field['type']]['label']); - $rows[$field_name]['data'][2][] = l($bundles[$obj_type][$bundle]['label'], $admin_path . '/fields'); + $rows[$field_name]['data'][2][] = l($bundles[$entity_type][$bundle]['label'], $admin_path . '/fields'); $rows[$field_name]['class'] = $field['locked'] ? array('menu-disabled') : array(''); } } @@ -44,8 +44,8 @@ function field_ui_fields_list() { /** * Helper function to display a message about inactive fields. */ -function field_ui_inactive_message($obj_type, $bundle) { - $inactive_instances = field_ui_inactive_instances($obj_type, $bundle); +function field_ui_inactive_message($entity_type, $bundle) { + $inactive_instances = field_ui_inactive_instances($entity_type, $bundle); if (!empty($inactive_instances)) { $field_types = field_info_field_types(); $widget_types = field_info_widget_types(); @@ -67,11 +67,11 @@ function field_ui_inactive_message($obj_type, $bundle) { * * Allows fields and pseudo-fields to be re-ordered. */ -function field_ui_field_overview_form($form, &$form_state, $obj_type, $bundle) { - $bundle = field_extract_bundle($obj_type, $bundle); +function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle) { + $bundle = field_extract_bundle($entity_type, $bundle); - field_ui_inactive_message($obj_type, $bundle); - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + field_ui_inactive_message($entity_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); // When displaying the form, make sure the list of fields is up-to-date. if (empty($form_state['post'])) { @@ -79,18 +79,18 @@ function field_ui_field_overview_form($form, &$form_state, $obj_type, $bundle) { } // Gather bundle information. - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); $field_types = field_info_field_types(); $widget_types = field_info_widget_types(); - $extra = field_extra_fields($obj_type, $bundle); + $extra = field_extra_fields($entity_type, $bundle); // Store each default weight so that we can add the 'add new' rows after them. $weights = array(); $form += array( '#tree' => TRUE, - '#object_type' => $obj_type, + '#object_type' => $entity_type, '#bundle' => $bundle, '#fields' => array_keys($instances), '#extra' => array_keys($extra), @@ -238,7 +238,7 @@ function field_ui_field_overview_form($form, &$form_state, $obj_type, $bundle) { } // Additional row: add existing field. - $existing_field_options = field_ui_existing_field_options($obj_type, $bundle); + $existing_field_options = field_ui_existing_field_options($entity_type, $bundle); if ($existing_field_options && $widget_type_options) { $weight++; array_unshift($existing_field_options, t('- Select an existing field -')); @@ -459,15 +459,15 @@ function _field_ui_field_overview_form_validate_add_existing($form, &$form_state */ function field_ui_field_overview_form_submit($form, &$form_state) { $form_values = $form_state['values']; - $obj_type = $form['#object_type']; + $entity_type = $form['#object_type']; $bundle = $form['#bundle']; - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); // Update field weights. $extra = array(); foreach ($form_values as $key => $values) { if (in_array($key, $form['#fields'])) { - $instance = field_read_instance($obj_type, $key, $bundle); + $instance = field_read_instance($entity_type, $key, $bundle); $instance['widget']['weight'] = $values['weight']; foreach($instance['display'] as $view_mode => $display) { $instance['display'][$view_mode]['weight'] = $values['weight']; @@ -480,7 +480,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) { } $extra_weights = variable_get('field_extra_weights', array()); - $extra_weights[$obj_type][$bundle] = $extra; + $extra_weights[$entity_type][$bundle] = $extra; variable_set('field_extra_weights', $extra_weights); $destinations = array(); @@ -497,7 +497,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) { ); $instance = array( 'field_name' => $field['field_name'], - 'object_type' => $obj_type, + 'object_type' => $entity_type, 'bundle' => $bundle, 'label' => $values['label'], 'widget' => array( @@ -532,7 +532,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) { else { $instance = array( 'field_name' => $field['field_name'], - 'object_type' => $obj_type, + 'object_type' => $entity_type, 'bundle' => $bundle, 'label' => $values['label'], 'widget' => array( @@ -567,20 +567,20 @@ function field_ui_field_overview_form_submit($form, &$form_state) { * This form includes form widgets to select which fields appear in teaser and * full view modes, and how the field labels should be rendered. */ -function field_ui_display_overview_form($form, &$form_state, $obj_type, $bundle, $view_modes_selector = 'basic') { - $bundle = field_extract_bundle($obj_type, $bundle); +function field_ui_display_overview_form($form, &$form_state, $entity_type, $bundle, $view_modes_selector = 'basic') { + $bundle = field_extract_bundle($entity_type, $bundle); - field_ui_inactive_message($obj_type, $bundle); - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + field_ui_inactive_message($entity_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); // Gather type information. - $instances = field_info_instances($obj_type, $bundle); + $instances = field_info_instances($entity_type, $bundle); $field_types = field_info_field_types(); - $view_modes = field_ui_view_modes_tabs($obj_type, $view_modes_selector); + $view_modes = field_ui_view_modes_tabs($entity_type, $view_modes_selector); $form += array( '#tree' => TRUE, - '#object_type' => $obj_type, + '#object_type' => $entity_type, '#bundle' => $bundle, '#fields' => array_keys($instances), '#contexts' => $view_modes_selector, @@ -777,14 +777,14 @@ function field_ui_formatter_options($field_type = NULL) { /** * Return an array of existing field to be added to a bundle. */ -function field_ui_existing_field_options($obj_type, $bundle) { +function field_ui_existing_field_options($entity_type, $bundle) { $options = array(); $field_types = field_info_field_types(); foreach (field_info_instances() as $existing_obj_type => $bundles) { foreach ($bundles as $existing_bundle => $instances) { // No need to look in the current bundle. - if (!($existing_bundle == $bundle && $existing_obj_type == $obj_type)) { + if (!($existing_bundle == $bundle && $existing_obj_type == $entity_type)) { foreach ($instances as $instance) { $field = field_info_field($instance['field_name']); // Don't show @@ -792,8 +792,8 @@ function field_ui_existing_field_options($obj_type, $bundle) { // - fields already in the current bundle, // - field that cannot be added to the object type. if (empty($field['locked']) - && !field_info_instance($obj_type, $field['field_name'], $bundle) - && (empty($field['object_types']) || in_array($obj_type, $field['object_types']))) { + && !field_info_instance($entity_type, $field['field_name'], $bundle) + && (empty($field['object_types']) || in_array($entity_type, $field['object_types']))) { $text = t('@type: @field (@label)', array( '@type' => $field_types[$field['type']]['label'], '@label' => t($instance['label']), '@field' => $instance['field_name'], @@ -812,9 +812,9 @@ function field_ui_existing_field_options($obj_type, $bundle) { /** * Menu callback; presents the field settings edit page. */ -function field_ui_field_settings_form($form, &$form_state, $obj_type, $bundle, $field) { - $bundle = field_extract_bundle($obj_type, $bundle); - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); +function field_ui_field_settings_form($form, &$form_state, $entity_type, $bundle, $field) { + $bundle = field_extract_bundle($entity_type, $bundle); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); // When a field is first created, we have to get data from the db. if (!isset($instance['label'])) { @@ -860,7 +860,7 @@ function field_ui_field_settings_form($form, &$form_state, $obj_type, $bundle, $ '#markup' => t('%field has no field settings.', array('%field' => $instance['label'])), ); } - $form['#object_type'] = $obj_type; + $form['#object_type'] = $entity_type; $form['#bundle'] = $bundle; $form['actions'] = array('#type' => 'container', '#attributes' => array('class' => array('form-actions'))); @@ -878,9 +878,9 @@ function field_ui_field_settings_form_submit($form, &$form_state) { // Merge incoming form values into the existing field. $field = field_info_field($field_values['field_name']); - $obj_type = $form['#object_type']; + $entity_type = $form['#object_type']; $bundle = $form['#bundle']; - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); // Update the field. $field = array_merge($field, $field_values); @@ -888,28 +888,28 @@ function field_ui_field_settings_form_submit($form, &$form_state) { try { field_update_field($field); drupal_set_message(t('Updated field %label field settings.', array('%label' => $instance['label']))); - $form_state['redirect'] = field_ui_next_destination($obj_type, $bundle); + $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle); } catch (FieldException $e) { drupal_set_message(t('Attempt to update field %label failed: %message.', array('%label' => $instance['label'], '%message' => $e->getMessage())), 'error'); // TODO: Where do we go from here? - $form_state['redirect'] = field_ui_next_destination($obj_type, $bundle); + $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle); } } /** * Menu callback; select a widget for the field. */ -function field_ui_widget_type_form($form, &$form_state, $obj_type, $bundle, $field) { - $bundle = field_extract_bundle($obj_type, $bundle); - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); +function field_ui_widget_type_form($form, &$form_state, $entity_type, $bundle, $field) { + $bundle = field_extract_bundle($entity_type, $bundle); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); drupal_set_title($instance['label']); $field_type = field_info_field_types($field['type']); $widget_type = field_info_widget_types($instance['widget']['type']); $bundles = field_info_bundles(); - $bundle_label = $bundles[$obj_type][$bundle]['label']; + $bundle_label = $bundles[$entity_type][$bundle]['label']; $form['basic'] = array( '#type' => 'fieldset', @@ -940,7 +940,7 @@ function field_ui_widget_type_form_submit($form, &$form_state) { $form_values = $form_state['values']; $instance = $form['#instance']; $bundle = $instance['bundle']; - $obj_type = $instance['object_type']; + $entity_type = $instance['object_type']; // Set the right module information. $widget_type = field_info_widget_types($form_values['widget_type']); @@ -956,18 +956,18 @@ function field_ui_widget_type_form_submit($form, &$form_state) { drupal_set_message(t('There was a problem changing the widget for field %label.', array('%label' => $instance['label']))); } - $form_state['redirect'] = field_ui_next_destination($obj_type, $bundle); + $form_state['redirect'] = field_ui_next_destination($entity_type, $bundle); } /** * Menu callback; present a form for removing a field from a content type. */ -function field_ui_field_delete_form($form, &$form_state, $obj_type, $bundle, $field) { - $bundle = field_extract_bundle($obj_type, $bundle); - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); +function field_ui_field_delete_form($form, &$form_state, $entity_type, $bundle, $field) { + $bundle = field_extract_bundle($entity_type, $bundle); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); - $form['object_type'] = array('#type' => 'value', '#value' => $obj_type); + $form['object_type'] = array('#type' => 'value', '#value' => $entity_type); $form['bundle'] = array('#type' => 'value', '#value' => $bundle); $form['field_name'] = array('#type' => 'value', '#value' => $field['field_name']); @@ -994,11 +994,11 @@ function field_ui_field_delete_form_submit($form, &$form_state) { $form_values = $form_state['values']; $field_name = $form_values['field_name']; $bundle = $form_values['bundle']; - $obj_type = $form_values['object_type']; + $entity_type = $form_values['object_type']; $field = field_info_field($form_values['field_name']); - $instance = field_info_instance($obj_type, $field_name, $bundle); + $instance = field_info_instance($entity_type, $field_name, $bundle); $bundles = field_info_bundles(); - $bundle_label = $bundles[$obj_type][$bundle]['label']; + $bundle_label = $bundles[$entity_type][$bundle]['label']; if (!empty($bundle) && $field && !$field['locked'] && $form_values['confirm']) { field_delete_instance($instance); @@ -1012,16 +1012,16 @@ function field_ui_field_delete_form_submit($form, &$form_state) { drupal_set_message(t('There was a problem removing the %field from the %type content type.', array('%field' => $instance['label'], '%type' => $bundle_label))); } - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); $form_state['redirect'] = field_ui_get_destinations(array($admin_path . '/fields')); } /** * Menu callback; presents the field instance edit page. */ -function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $field) { - $bundle = field_extract_bundle($obj_type, $bundle); - $instance = field_info_instance($obj_type, $field['field_name'], $bundle); +function field_ui_field_edit_form($form, &$form_state, $entity_type, $bundle, $field) { + $bundle = field_extract_bundle($entity_type, $bundle); + $instance = field_info_instance($entity_type, $field['field_name'], $bundle); $form['#field'] = $field; @@ -1043,8 +1043,8 @@ function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $fiel $form['instance'] = array( '#tree' => TRUE, '#type' => 'fieldset', - '#title' => t('%type settings', array('%type' => $bundles[$obj_type][$bundle]['label'])), - '#description' => t('These settings apply only to the %field field when used in the %type type.', array('%field' => $instance['label'], '%type' => $bundles[$obj_type][$bundle]['label'])), + '#title' => t('%type settings', array('%type' => $bundles[$entity_type][$bundle]['label'])), + '#description' => t('These settings apply only to the %field field when used in the %type type.', array('%field' => $instance['label'], '%type' => $bundles[$entity_type][$bundle]['label'])), '#pre_render' => array('field_ui_field_edit_instance_pre_render'), ); @@ -1055,7 +1055,7 @@ function field_ui_field_edit_form($form, &$form_state, $obj_type, $bundle, $fiel ); $form['instance']['object_type'] = array( '#type' => 'value', - '#value' => $obj_type, + '#value' => $entity_type, ); $form['instance']['bundle'] = array( '#type' => 'value', @@ -1296,13 +1296,13 @@ function field_ui_get_destinations($destinations) { /** * Return the next redirect path in a multipage sequence. */ -function field_ui_next_destination($obj_type, $bundle) { +function field_ui_next_destination($entity_type, $bundle) { $destinations = !empty($_REQUEST['destinations']) ? $_REQUEST['destinations'] : array(); if (!empty($destinations)) { unset($_REQUEST['destinations']); return field_ui_get_destinations($destinations); } - $admin_path = _field_ui_bundle_admin_path($obj_type, $bundle); + $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle); return $admin_path . '/fields'; } diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module index 411375388..d9ee659a4 100644 --- a/modules/field_ui/field_ui.module +++ b/modules/field_ui/field_ui.module @@ -48,7 +48,7 @@ function field_ui_menu() { return $items; } // Create tabs for all possible bundles. - foreach (entity_get_info() as $obj_type => $info) { + foreach (entity_get_info() as $entity_type => $info) { if ($info['fieldable']) { foreach ($info['bundles'] as $bundle_name => $bundle_info) { if (isset($bundle_info['admin'])) { @@ -61,38 +61,38 @@ function field_ui_menu() { $items["$path/fields"] = array( 'title' => 'Manage fields', 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_overview_form', $obj_type, $bundle_arg), + 'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg), 'type' => MENU_LOCAL_TASK, 'weight' => 1, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu"] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $field_position), + 'page arguments' => array('field_ui_field_edit_form', $entity_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/edit"] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_edit_form', $obj_type, $bundle_arg, $field_position), + 'page arguments' => array('field_ui_field_edit_form', $entity_type, $bundle_arg, $field_position), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/field-settings"] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_settings_form', $obj_type, $bundle_arg, $field_position), + 'page arguments' => array('field_ui_field_settings_form', $entity_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/widget-type"] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_widget_type_form', $obj_type, $bundle_arg, $field_position), + 'page arguments' => array('field_ui_widget_type_form', $entity_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/delete"] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_delete_form', $obj_type, $bundle_arg, $field_position), + 'page arguments' => array('field_ui_field_delete_form', $entity_type, $bundle_arg, $field_position), 'type' => MENU_LOCAL_TASK, 'file' => 'field_ui.admin.inc', ) + $access; @@ -101,16 +101,16 @@ function field_ui_menu() { $items["$path/display"] = array( 'title' => 'Manage display', 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg), + 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'field_ui.admin.inc', ) + $access; - $tabs = field_ui_view_modes_tabs($obj_type); + $tabs = field_ui_view_modes_tabs($entity_type); foreach ($tabs as $key => $tab) { $items["$path/display/$key"] = array( 'title' => $tab['title'], - 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg, $key), + 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, $key), 'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, 'weight' => $key == 'basic' ? 0 : 1, 'file' => 'field_ui.admin.inc', @@ -156,32 +156,32 @@ function field_ui_theme() { * * @todo Remove this completely and use vertical tabs? */ -function field_ui_view_modes_tabs($obj_type, $tab_selector = NULL) { +function field_ui_view_modes_tabs($entity_type, $tab_selector = NULL) { $info = &drupal_static(__FUNCTION__); - if (!isset($info[$obj_type])) { - $info[$obj_type] = module_invoke_all('field_ui_view_modes_tabs', $obj_type); + if (!isset($info[$entity_type])) { + $info[$entity_type] = module_invoke_all('field_ui_view_modes_tabs', $entity_type); // Filter out inactive modes. - $entity_info = entity_get_info($obj_type); - foreach ($info[$obj_type] as $tab => $values) { + $entity_info = entity_get_info($entity_type); + foreach ($info[$entity_type] as $tab => $values) { $modes = array(); - foreach ($info[$obj_type][$tab]['view modes'] as $mode) { + foreach ($info[$entity_type][$tab]['view modes'] as $mode) { if (isset($entity_info['view modes'][$mode])) { $modes[] = $mode; } } if ($modes) { - $info[$obj_type][$tab]['view modes'] = $modes; + $info[$entity_type][$tab]['view modes'] = $modes; } else { - unset($info[$obj_type][$tab]); + unset($info[$entity_type][$tab]); } } } if ($tab_selector) { - return isset($info[$obj_type][$tab_selector]) ? $info[$obj_type][$tab_selector]['view modes'] : array(); + return isset($info[$entity_type][$tab_selector]) ? $info[$entity_type][$tab_selector]['view modes'] : array(); } - return $info[$obj_type]; + return $info[$entity_type]; } /** @@ -229,7 +229,7 @@ function field_ui_field_ui_view_modes_tabs() { /** * Implements hook_field_attach_create_bundle(). */ -function field_ui_field_attach_create_bundle($obj_type, $bundle) { +function field_ui_field_attach_create_bundle($entity_type, $bundle) { // When a new bundle is created, the menu needs to be rebuilt to add our // menu item tabs. variable_set('menu_rebuild_needed', TRUE); @@ -238,12 +238,12 @@ function field_ui_field_attach_create_bundle($obj_type, $bundle) { /** * Implements hook_field_attach_rename_bundle(). */ -function field_ui_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new) { +function field_ui_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { if ($bundle_old !== $bundle_new) { $extra_weights = variable_get('field_extra_weights', array()); - if (isset($info[$obj_type][$bundle_old])) { - $extra_weights[$obj_type][$bundle_new] = $extra_weights[$obj_type][$bundle_old]; - unset($extra_weights[$obj_type][$bundle_old]); + if (isset($info[$entity_type][$bundle_old])) { + $extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old]; + unset($extra_weights[$entity_type][$bundle_old]); variable_set('field_extra_weights', $extra_weights); } } @@ -252,10 +252,10 @@ function field_ui_field_attach_rename_bundle($obj_type, $bundle_old, $bundle_new /** * Implements hook_field_attach_delete_bundle(). */ -function field_ui_field_attach_delete_bundle($obj_type, $bundle) { +function field_ui_field_attach_delete_bundle($entity_type, $bundle) { $extra_weights = variable_get('field_extra_weights', array()); - if (isset($extra_weights[$obj_type][$bundle])) { - unset($extra_weights[$obj_type][$bundle]); + if (isset($extra_weights[$entity_type][$bundle])) { + unset($extra_weights[$entity_type][$bundle]); variable_set('field_extra_weights', $extra_weights); } } @@ -263,8 +263,8 @@ function field_ui_field_attach_delete_bundle($obj_type, $bundle) { /** * Helper function to create the right administration path for a bundle. */ -function _field_ui_bundle_admin_path($obj_type, $bundle_name) { - $bundles = field_info_bundles($obj_type); +function _field_ui_bundle_admin_path($entity_type, $bundle_name) { + $bundles = field_info_bundles($entity_type); $bundle_info = $bundles[$bundle_name]; return isset($bundle_info['admin']['real path']) ? $bundle_info['admin']['real path'] : $bundle_info['admin']['path']; } @@ -272,7 +272,7 @@ function _field_ui_bundle_admin_path($obj_type, $bundle_name) { /** * Helper function to identify inactive fields within a bundle. */ -function field_ui_inactive_instances($obj_type, $bundle_name = NULL) { +function field_ui_inactive_instances($entity_type, $bundle_name = NULL) { if (!empty($bundle_name)) { $inactive = array($bundle_name => array()); $params = array('bundle' => $bundle_name); @@ -281,9 +281,9 @@ function field_ui_inactive_instances($obj_type, $bundle_name = NULL) { $inactive = array(); $params = array(); } - $params['object_type'] = $obj_type; + $params['object_type'] = $entity_type; - $active_instances = field_info_instances($obj_type); + $active_instances = field_info_instances($entity_type); $all_instances = field_read_instances($params, array('include_inactive' => TRUE)); foreach ($all_instances as $instance) { if (!isset($active_instances[$instance['bundle']][$instance['field_name']])) { diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index e3f030782..624ddd3e5 100644 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -205,10 +205,10 @@ class FieldUITestCase extends DrupalWebTestCase { * The field name for the instance. * @param $string * The settings text. - * @param $obj_type + * @param $entity_type * The object type for the instance. */ - function assertFieldSettings($bundle, $field_name, $string = 'dummy test string', $obj_type = 'node') { + function assertFieldSettings($bundle, $field_name, $string = 'dummy test string', $entity_type = 'node') { // Reset the fields info. _field_info_collate_fields(TRUE); // Assert field settings. @@ -216,7 +216,7 @@ class FieldUITestCase extends DrupalWebTestCase { $this->assertTrue($field['settings']['test_field_setting'] == $string, t('Field settings were found.')); // Assert instance and widget settings. - $instance = field_info_instance($obj_type, $field_name, $bundle); + $instance = field_info_instance($entity_type, $field_name, $bundle); $this->assertTrue($instance['settings']['test_instance_setting'] == $string, t('Field instance settings were found.')); $this->assertTrue($instance['widget']['settings']['test_widget_setting'] == $string, t('Field widget settings were found.')); } diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 20f881675..fe55c8cca 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -204,8 +204,8 @@ function _file_generic_settings_file_directory_validate($element, &$form_state) /** * Implements hook_field_load(). */ -function file_field_load($obj_type, $objects, $field, $instances, $langcode, &$items, $age) { - foreach ($objects as $obj_id => $object) { +function file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { + foreach ($entities as $obj_id => $entity) { // Load the files from the files table. $fids = array(); foreach ($items[$obj_id] as $delta => $item) { @@ -228,9 +228,9 @@ function file_field_load($obj_type, $objects, $field, $instances, $langcode, &$i /** * Implements hook_field_prepare_view(). */ -function file_field_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items) { +function file_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { // Remove files specified to not be displayed. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { if (!file_field_displayed($item, $field)) { unset($items[$id][$delta]); @@ -246,9 +246,9 @@ function file_field_prepare_view($obj_type, $objects, $field, $instances, $langc * * Check for files that have been removed from the object. */ -function file_field_update($obj_type, $object, $field, $instance, $langcode, &$items) { +function file_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { // On new revisions, old files are always maintained in the previous revision. - if (!empty($object->revision)) { + if (!empty($entity->revision)) { return; } @@ -259,8 +259,8 @@ function file_field_update($obj_type, $object, $field, $instance, $langcode, &$i } // Delete items from original object. - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); - $load_function = $obj_type . '_load'; + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); + $load_function = $entity_type . '_load'; $original = $load_function($id); if (!empty($original->{$field['field_name']}[$langcode])) { @@ -278,14 +278,14 @@ function file_field_update($obj_type, $object, $field, $instance, $langcode, &$i /** * Implements hook_field_delete(). */ -function file_field_delete($obj_type, $object, $field, $instance, $langcode, &$items) { - list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object); +function file_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); foreach ($items as $delta => $item) { // For hook_file_references(), remember that this is being deleted. $item['file_field_name'] = $field['field_name']; // Pass in the ID of the object that is being removed so all references can // be counted in hook_file_references(). - $item['file_field_type'] = $obj_type; + $item['file_field_type'] = $entity_type; $item['file_field_id'] = $id; file_field_delete_file($item, $field); } @@ -294,7 +294,7 @@ function file_field_delete($obj_type, $object, $field, $instance, $langcode, &$i /** * Implements hook_field_delete_revision(). */ -function file_field_delete_revision($obj_type, $object, $field, $instance, $langcode, &$items) { +function file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { foreach ($items as $delta => $item) { // For hook_file_references, remember that this file is being deleted. $item['file_field_name'] = $field['field_name']; @@ -832,7 +832,7 @@ function theme_file_upload_help($variables) { /** * Implements hook_field_formatter_view(). */ -function file_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) { +function file_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { diff --git a/modules/file/file.module b/modules/file/file.module index 1b56ea595..875d0abbc 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -139,13 +139,13 @@ function file_file_download($uri, $field_type = 'file') { // Check access to content containing the file fields. If access is allowed // to any of this content, allow the download. foreach ($references as $field_name => $field_references) { - foreach ($field_references as $obj_type => $type_references) { + foreach ($field_references as $entity_type => $type_references) { foreach ($type_references as $reference) { // If access is allowed to any object, immediately stop and grant // access. If access is denied, continue through in case another object // grants access. // TODO: Switch this to a universal access check mechanism if available. - if ($obj_type == 'node' && ($node = node_load($reference->nid))) { + if ($entity_type == 'node' && ($node = node_load($reference->nid))) { if (node_access('view', $node)) { $denied = FALSE; break 3; @@ -154,7 +154,7 @@ function file_file_download($uri, $field_type = 'file') { $denied = TRUE; } } - if ($obj_type == 'user') { + if ($entity_type == 'user') { if (user_access('access user profiles') || $user->uid == $reference->uid) { $denied = FALSE; break 3; @@ -904,7 +904,7 @@ function file_get_file_reference_count($file, $field = NULL, $field_type = 'file // TODO: Use a more efficient mechanism rather than actually retrieving // all the references themselves, such as using a COUNT() query. $references = file_get_file_references($file, $field, FIELD_LOAD_REVISION, $field_type); - foreach ($references as $obj_type => $type_references) { + foreach ($references as $entity_type => $type_references) { $reference_count += count($type_references); } @@ -913,9 +913,9 @@ function file_get_file_reference_count($file, $field = NULL, $field_type = 'file if (isset($file->file_field_name) && $field['field_name'] == $file->file_field_name) { // If deleting the entire piece of content, decrement references. if (isset($file->file_field_type) && isset($file->file_field_id)) { - if ($file->file_field_type == $obj_type) { - $info = entity_get_info($obj_type); - $id = $types[$obj_type]['object keys']['id']; + if ($file->file_field_type == $entity_type) { + $info = entity_get_info($entity_type); + $id = $types[$entity_type]['object keys']['id']; foreach ($type_references as $reference) { if ($file->file_field_id == $reference->$id) { $reference_count--; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 64bb5f5a8..e21217204 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -495,19 +495,19 @@ function forum_comment_delete($comment) { /** * Implements hook_field_storage_pre_insert(). */ -function forum_field_storage_pre_insert($obj_type, $object, &$skip_fields) { - if ($obj_type == 'node' && $object->status && _forum_node_check_node_type($object)) { +function forum_field_storage_pre_insert($entity_type, $entity, &$skip_fields) { + if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($object->taxonomy_forums as $language) { + foreach ($entity->taxonomy_forums as $language) { foreach ($language as $item) { $query->values(array( - 'nid' => $object->nid, - 'title' => $object->title, + 'nid' => $entity->nid, + 'title' => $entity->title, 'tid' => $item['tid'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, 'comment_count' => 0, - 'last_comment_timestamp' => $object->created, + 'last_comment_timestamp' => $entity->created, )); } } @@ -518,37 +518,37 @@ function forum_field_storage_pre_insert($obj_type, $object, &$skip_fields) { /** * Implements hook_field_storage_pre_update(). */ -function forum_field_storage_pre_update($obj_type, $object, &$skip_fields) { +function forum_field_storage_pre_update($entity_type, $entity, &$skip_fields) { $first_call = &drupal_static(__FUNCTION__, array()); - if ($obj_type == 'node' && $object->status && _forum_node_check_node_type($object)) { + if ($entity_type == 'node' && $entity->status && _forum_node_check_node_type($entity)) { // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. - if (!isset($first_call[$object->nid])) { - $first_call[$object->nid] = FALSE; - db_delete('forum_index')->condition('nid', $object->nid)->execute(); + if (!isset($first_call[$entity->nid])) { + $first_call[$entity->nid] = FALSE; + db_delete('forum_index')->condition('nid', $entity->nid)->execute(); } // Only save data to the table if the node is published. - if ($object->status) { + if ($entity->status) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($object->taxonomy_forums as $language) { + foreach ($entity->taxonomy_forums as $language) { foreach ($language as $item) { $query->values(array( - 'nid' => $object->nid, - 'title' => $object->title, + 'nid' => $entity->nid, + 'title' => $entity->title, 'tid' => $item['tid'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, 'comment_count' => 0, - 'last_comment_timestamp' => $object->created, + 'last_comment_timestamp' => $entity->created, )); } } $query->execute(); // The logic for determining last_comment_count is fairly complex, so // call _forum_update_forum_index() too. - _forum_update_forum_index($object->nid); + _forum_update_forum_index($entity->nid); } } } diff --git a/modules/image/image.field.inc b/modules/image/image.field.inc index f1fc8993f..77ce16e53 100644 --- a/modules/image/image.field.inc +++ b/modules/image/image.field.inc @@ -203,16 +203,16 @@ function _image_field_resolution_validate($element, &$form_state) { /** * Implements hook_field_load(). */ -function image_field_load($obj_type, $objects, $field, $instances, $langcode, &$items, $age) { - file_field_load($obj_type, $objects, $field, $instances, $langcode, $items, $age); +function image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { + file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age); } /** * Implements hook_field_prepare_view(). */ -function image_field_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items) { +function image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) { // If there are no files specified at all, use the default. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { if (empty($items[$id]) && $field['settings']['default_image']) { if ($file = file_load($field['settings']['default_image'])) { $items[$id][0] = (array) $file + array( @@ -228,29 +228,29 @@ function image_field_prepare_view($obj_type, $objects, $field, $instances, $lang /** * Implements hook_field_insert(). */ -function image_field_insert($obj_type, $object, $field, $instance, $langcode, &$items) { - image_field_update($obj_type, $object, $field, $instance, $langcode, $items); +function image_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { + image_field_update($entity_type, $entity, $field, $instance, $langcode, $items); } /** * Implements hook_field_update(). */ -function image_field_update($obj_type, $object, $field, $instance, $langcode, &$items) { - file_field_update($obj_type, $object, $field, $instance, $langcode, $items); +function image_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { + file_field_update($entity_type, $entity, $field, $instance, $langcode, $items); } /** * Implements hook_field_delete(). */ -function image_field_delete($obj_type, $object, $field, $instance, $langcode, &$items) { - file_field_delete($obj_type, $object, $field, $instance, $langcode, $items); +function image_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) { + file_field_delete($entity_type, $entity, $field, $instance, $langcode, $items); } /** * Implements hook_field_delete_revision(). */ -function image_field_delete_revision($obj_type, $object, $field, $instance, $langcode, &$items) { - file_field_delete_revision($obj_type, $object, $field, $instance, $langcode, $items); +function image_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) { + file_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, $items); } /** @@ -450,7 +450,7 @@ function image_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function image_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) { +function image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); // Check if the formatter involves a particular image style. @@ -461,7 +461,7 @@ function image_field_formatter_view($obj_type, $object, $field, $instance, $lang // Check if the formatter involves a link. if (strpos($display['type'], 'image_link_content') === 0) { - $uri = entity_uri($obj_type, $object); + $uri = entity_uri($entity_type, $entity); } elseif (strpos($display['type'], 'image_link_file') === 0) { $link_file = TRUE; diff --git a/modules/node/node.install b/modules/node/node.install index f099fffb1..b4eeaeab6 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -427,7 +427,7 @@ function node_update_7004() { $type_list = node_type_get_types(); // Apply original settings to all types. - foreach ($type_list as $type => $object) { + foreach ($type_list as $type => $entity) { variable_set('teaser_length_' . $type, $original_length); variable_set('node_preview_' . $type, $original_preview); } diff --git a/modules/node/node.module b/modules/node/node.module index 6b5265b25..3c556914b 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2519,8 +2519,8 @@ function node_form_search_form_alter(&$form, $form_state) { // Languages: $language_options = array(); - foreach (language_list('language') as $key => $object) { - $language_options[$key] = $object->name; + foreach (language_list('language') as $key => $entity) { + $language_options[$key] = $entity->name; } if (count($language_options) > 1) { $form['advanced']['language'] = array( @@ -3489,8 +3489,8 @@ class NodeController extends DrupalDefaultEntityController { // Create an array of nodes for each content type and pass this to the // object type specific callback. $typed_nodes = array(); - foreach ($nodes as $id => $object) { - $typed_nodes[$object->type][$id] = $object; + foreach ($nodes as $id => $entity) { + $typed_nodes[$entity->type][$id] = $entity; } // Call object type specific callbacks on each typed array of nodes. diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 6c617edf7..7b64d46c4 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -24,8 +24,8 @@ class DrupalAlterTestCase extends DrupalWebTestCase { function testDrupalAlter() { $array = array('foo' => 'bar'); - $object = new stdClass; - $object->foo = 'bar'; + $entity = new stdClass; + $entity->foo = 'bar'; // Verify alteration of a single argument. $array_copy = $array; @@ -33,23 +33,23 @@ class DrupalAlterTestCase extends DrupalWebTestCase { drupal_alter('drupal_alter', $array_copy); $this->assertEqual($array_copy, $array_expected, t('Single array was altered.')); - $object_copy = clone $object; - $object_expected = clone $object; - $object_expected->foo = 'Drupal theme'; - drupal_alter('drupal_alter', $object_copy); - $this->assertEqual($object_copy, $object_expected, t('Single object was altered.')); + $entity_copy = clone $entity; + $entity_expected = clone $entity; + $entity_expected->foo = 'Drupal theme'; + drupal_alter('drupal_alter', $entity_copy); + $this->assertEqual($entity_copy, $entity_expected, t('Single object was altered.')); // Verify alteration of multiple arguments. $array_copy = $array; $array_expected = array('foo' => 'Drupal theme'); - $object_copy = clone $object; - $object_expected = clone $object; - $object_expected->foo = 'Drupal theme'; + $entity_copy = clone $entity; + $entity_expected = clone $entity; + $entity_expected->foo = 'Drupal theme'; $array2_copy = $array; $array2_expected = array('foo' => 'Drupal theme'); - drupal_alter('drupal_alter', $array_copy, $object_copy, $array2_copy); + drupal_alter('drupal_alter', $array_copy, $entity_copy, $array2_copy); $this->assertEqual($array_copy, $array_expected, t('First argument to drupal_alter() was altered.')); - $this->assertEqual($object_copy, $object_expected, t('Second argument to drupal_alter() was altered.')); + $this->assertEqual($entity_copy, $entity_expected, t('Second argument to drupal_alter() was altered.')); $this->assertEqual($array2_copy, $array2_expected, t('Third argument to drupal_alter() was altered.')); } } diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 2245f4c6b..644f16b2a 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1407,12 +1407,12 @@ function hook_mail($key, &$message, $params) { '%username' => format_username($account), ); if ($context['hook'] == 'taxonomy') { - $object = $params['object']; - $vocabulary = taxonomy_vocabulary_load($object->vid); + $entity = $params['object']; + $vocabulary = taxonomy_vocabulary_load($entity->vid); $variables += array( - '%term_name' => $object->name, - '%term_description' => $object->description, - '%term_id' => $object->tid, + '%term_name' => $entity->name, + '%term_description' => $entity->description, + '%term_id' => $entity->tid, '%vocabulary_name' => $vocabulary->name, '%vocabulary_description' => $vocabulary->description, '%vocabulary_id' => $vocabulary->vid, diff --git a/modules/system/system.module b/modules/system/system.module index 606d6610d..96402841d 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2848,9 +2848,9 @@ function system_send_email_action_submit($form, $form_state) { /** * Implements a configurable Drupal action: sends an email. */ -function system_send_email_action($object, $context) { +function system_send_email_action($entity, $context) { if (empty($context['node'])) { - $context['node'] = $object; + $context['node'] = $entity; } $recipient = token_replace($context['recipient'], $context); @@ -2898,9 +2898,9 @@ function system_message_action_submit($form, $form_state) { /** * A configurable Drupal action. Sends a message to the current user's screen. */ -function system_message_action(&$object, $context = array()) { +function system_message_action(&$entity, $context = array()) { if (empty($context['node'])) { - $context['node'] = $object; + $context['node'] = $entity; } $context['message'] = token_replace($context['message'], $context); @@ -2927,7 +2927,7 @@ function system_goto_action_submit($form, $form_state) { ); } -function system_goto_action($object, $context) { +function system_goto_action($entity, $context) { drupal_goto(token_replace($context['url'], $context)); } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index d976c4982..2a03f2d47 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -1126,7 +1126,7 @@ function taxonomy_field_schema($field) { * Possible error codes: * - 'taxonomy_term_illegal_value': The value is not part of the list of allowed values. */ -function taxonomy_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) { +function taxonomy_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { // Build an array of term IDs so they can be loaded with // taxonomy_term_load_multiple(); foreach ($items as $delta => $item) { @@ -1203,7 +1203,7 @@ function taxonomy_field_formatter_info() { /** * Implements hook_field_formatter_view(). */ -function taxonomy_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) { +function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { @@ -1258,11 +1258,11 @@ function taxonomy_allowed_values($field) { * This preloads all taxonomy terms for multiple loaded objects at once and * unsets values for invalid terms that do not exist. */ -function taxonomy_field_formatter_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $displays) { +function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) { $tids = array(); // Collect every possible term attached to any of the fieldable entities. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Force the array key to prevent duplicates. $tids[$item['tid']] = $item['tid']; @@ -1272,7 +1272,7 @@ function taxonomy_field_formatter_prepare_view($obj_type, $objects, $field, $ins $terms = taxonomy_term_load_multiple($tids); // Iterate through the fieldable entities again to attach the loaded term data. - foreach ($objects as $id => $object) { + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Check whether the taxonomy term field instance value could be loaded. if (isset($terms[$item['tid']])) { @@ -1470,17 +1470,17 @@ function taxonomy_rdf_mapping() { /** * Implements hook_field_insert(). */ -function taxonomy_field_insert($obj_type, $object, $field, $instance, $langcode, &$items) { +function taxonomy_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) { // We maintain a denormalized table of term/node relationships, containing // only data for current, published nodes. - if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $obj_type == 'node' && $object->status) { + if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) { $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', )); foreach ($items as $item) { $query->values(array( - 'nid' => $object->nid, + 'nid' => $entity->nid, 'tid' => $item['tid'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, )); } $query->execute(); @@ -1490,26 +1490,26 @@ function taxonomy_field_insert($obj_type, $object, $field, $instance, $langcode, /** * Implements hook_field_update(). */ -function taxonomy_field_update($obj_type, $object, $field, $instance, $langcode, &$items) { - if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $obj_type == 'node') { +function taxonomy_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { + if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') { $first_call = &drupal_static(__FUNCTION__, array()); // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. - if (!isset($first_call[$object->nid])) { - $first_call[$object->nid] = FALSE; - db_delete('taxonomy_index')->condition('nid', $object->nid)->execute(); + if (!isset($first_call[$entity->nid])) { + $first_call[$entity->nid] = FALSE; + db_delete('taxonomy_index')->condition('nid', $entity->nid)->execute(); } // Only save data to the table if the node is published. - if ($object->status) { + if ($entity->status) { $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created')); foreach ($items as $item) { $query->values(array( - 'nid' => $object->nid, + 'nid' => $entity->nid, 'tid' => $item['tid'], - 'sticky' => $object->sticky, - 'created' => $object->created, + 'sticky' => $entity->sticky, + 'created' => $entity->created, )); } $query->execute(); diff --git a/modules/user/user.module b/modules/user/user.module index 87ffe3a77..9417f57a8 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -471,8 +471,8 @@ function user_save($account, $edit = array(), $category = 'account') { } // Save Field data. - $object = (object) $edit; - field_attach_update('user', $object); + $entity = (object) $edit; + field_attach_update('user', $entity); // Refresh user object. $user = user_load($account->uid, TRUE); @@ -514,8 +514,8 @@ function user_save($account, $edit = array(), $category = 'account') { // Build the initial user object. $user = user_load($edit['uid'], TRUE); - $object = (object) $edit; - field_attach_insert('user', $object); + $entity = (object) $edit; + field_attach_insert('user', $entity); user_module_invoke('insert', $edit, $user, $category); entity_invoke('insert', 'user', $user); @@ -3235,9 +3235,9 @@ function user_action_info() { * Implement a Drupal action. * Blocks the current user. */ -function user_block_user_action(&$object, $context = array()) { - if (isset($object->uid)) { - $uid = $object->uid; +function user_block_user_action(&$entity, $context = array()) { + if (isset($entity->uid)) { + $uid = $entity->uid; } elseif (isset($context['uid'])) { $uid = $context['uid']; |