summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-11 17:44:47 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-11 17:44:47 +0000
commit7562a8efb36306e96bf4d13b1f97b4573809ab45 (patch)
tree998dfd1d27d9c1a691a83a0c0e37d783d4fc4a44 /modules/field
parent52195a6b1dd478875a93935df27d7bcacb14f289 (diff)
downloadbrdo-7562a8efb36306e96bf4d13b1f97b4573809ab45.tar.gz
brdo-7562a8efb36306e96bf4d13b1f97b4573809ab45.tar.bz2
#707724 by chx: Rename confusing arguments in field/entity APIs.
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.api.php264
-rw-r--r--modules/field/field.attach.inc376
-rw-r--r--modules/field/field.crud.inc38
-rw-r--r--modules/field/field.default.inc66
-rw-r--r--modules/field/field.form.inc12
-rw-r--r--modules/field/field.info.inc42
-rw-r--r--modules/field/field.module94
-rw-r--r--modules/field/field.multilingual.inc14
-rw-r--r--modules/field/modules/field_sql_storage/field_sql_storage.module64
-rw-r--r--modules/field/modules/field_sql_storage/field_sql_storage.test4
-rw-r--r--modules/field/modules/list/list.module4
-rw-r--r--modules/field/modules/number/number.module6
-rw-r--r--modules/field/modules/text/text.module8
-rw-r--r--modules/field/tests/field.test34
-rw-r--r--modules/field/tests/field_test.entity.inc8
-rw-r--r--modules/field/tests/field_test.field.inc12
-rw-r--r--modules/field/tests/field_test.module24
-rw-r--r--modules/field/tests/field_test.storage.inc48
18 files changed, 559 insertions, 559 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]);
}
}