Commit 7d4b84b8 authored by webchick's avatar webchick

#707724 follow-up by yched: Fix more confusing field/entity api arguments.

parent f86fda29
......@@ -6251,11 +6251,11 @@ function entity_get_info($entity_type = NULL) {
'load hook' => $name . '_load',
'bundles' => array(),
'view modes' => array(),
'object keys' => array(),
'entity keys' => array(),
'cacheable' => TRUE,
'translation' => array(),
);
$entity_info[$name]['object keys'] += array(
$entity_info[$name]['entity keys'] += array(
'revision' => '',
'bundle' => '',
);
......@@ -6306,11 +6306,11 @@ function entity_info_cache_clear() {
function entity_extract_ids($entity_type, $entity) {
$info = entity_get_info($entity_type);
// Objects being created might not have id/vid yet.
$id = isset($entity->{$info['object keys']['id']}) ? $entity->{$info['object keys']['id']} : NULL;
$vid = ($info['object keys']['revision'] && isset($entity->{$info['object keys']['revision']})) ? $entity->{$info['object keys']['revision']} : NULL;
$id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL;
$vid = ($info['entity keys']['revision'] && isset($entity->{$info['entity keys']['revision']})) ? $entity->{$info['entity keys']['revision']} : NULL;
// If no bundle key provided, then we assume a single bundle, named after the
// entity type.
$bundle = $info['object keys']['bundle'] ? $entity->{$info['object keys']['bundle']} : $entity_type;
$bundle = $info['entity keys']['bundle'] ? $entity->{$info['entity keys']['bundle']} : $entity_type;
$cacheable = $info['cacheable'];
return array($id, $vid, $bundle, $cacheable);
}
......@@ -6334,12 +6334,12 @@ function entity_extract_ids($entity_type, $entity) {
function entity_create_stub_entity($entity_type, $ids) {
$entity = new stdClass();
$info = entity_get_info($entity_type);
$entity->{$info['object keys']['id']} = $ids[0];
if (isset($info['object keys']['revision']) && !is_null($ids[1])) {
$entity->{$info['object keys']['revision']} = $ids[1];
$entity->{$info['entity keys']['id']} = $ids[0];
if (isset($info['entity keys']['revision']) && !is_null($ids[1])) {
$entity->{$info['entity keys']['revision']} = $ids[1];
}
if ($info['object keys']['bundle']) {
$entity->{$info['object keys']['bundle']} = $ids[2];
if ($info['entity keys']['bundle']) {
$entity->{$info['entity keys']['bundle']} = $ids[2];
}
return $entity;
}
......
......@@ -64,11 +64,11 @@ public function __construct($entityType) {
$this->entityInfo = entity_get_info($entityType);
$this->entityCache = array();
$this->hookLoadArguments = array();
$this->idKey = $this->entityInfo['object keys']['id'];
$this->idKey = $this->entityInfo['entity keys']['id'];
// Check if the entity type supports revisions.
if (!empty($this->entityInfo['object keys']['revision'])) {
$this->revisionKey = $this->entityInfo['object keys']['revision'];
if (!empty($this->entityInfo['entity keys']['revision'])) {
$this->revisionKey = $this->entityInfo['entity keys']['revision'];
$this->revisionTable = $this->entityInfo['revision table'];
}
else {
......
......@@ -55,7 +55,7 @@ function comment_enable() {
$field = array(
'field_name' => 'comment_body',
'type' => 'text_long',
'object_types' => array('comment'),
'entity_types' => array('comment'),
);
field_create_field($field);
}
......@@ -269,7 +269,7 @@ function comment_update_7012() {
$field = array(
'field_name' => 'comment_body',
'type' => 'text_long',
'object_types' => array('comment'),
'entity_types' => array('comment'),
);
field_create_field($field);
......@@ -277,7 +277,7 @@ function comment_update_7012() {
$body_instance = array(
'field_name' => 'comment_body',
'label' => 'Comment',
'object_type' => 'comment',
'entity_type' => 'comment',
'settings' => array('text_processing' => 1),
// Hide field label by default.
'display' => array(
......
......@@ -100,7 +100,7 @@ function comment_entity_info() {
'uri callback' => 'comment_uri',
'fieldable' => TRUE,
'controller class' => 'CommentController',
'object keys' => array(
'entity keys' => array(
'id' => 'cid',
'bundle' => 'node_type',
),
......@@ -343,7 +343,7 @@ function _comment_body_field_instance_create($info) {
$instance = array(
'field_name' => 'comment_body',
'label' => 'Comment',
'object_type' => 'comment',
'entity_type' => 'comment',
'bundle' => 'comment_node_' . $info->type,
'settings' => array('text_processing' => 1),
'required' => TRUE,
......
......@@ -659,7 +659,7 @@ function hook_field_widget_info_alter(&$info) {
* The order of this item in the array of subelements (0, 1, 2, etc).
* @param $element
* A form element array containing basic properties for the widget:
* - #object_type: The name of the entity the field is attached to.
* - #entity_type: The name of the entity the field is attached to.
* - #bundle: The name of the field bundle the field is contained in.
* - #field_name: The name of the field.
* - #language: The language the field is being edited in.
......@@ -1023,7 +1023,7 @@ function hook_field_attach_update($entity_type, $entity) {
* values.
* @param $context
* An associative array containing:
* - obj_type: The type of $entity; e.g. 'node' or 'user'.
* - entity_type: The type of $entity; e.g. 'node' or 'user'.
* - object: The entity with fields to render.
* - element: The structured array containing the values ready for rendering.
*/
......@@ -1059,7 +1059,7 @@ function hook_field_attach_delete_revision($entity_type, $entity) {
* The structured content array tree for all of $entity's fields.
* @param $context
* An associative array containing:
* - obj_type: The type of $entity; e.g. 'node' or 'user'.
* - entity_type: The type of $entity; e.g. 'node' or 'user'.
* - object: The entity with fields to render.
* - view_mode: View mode, e.g. 'full', 'teaser'...
*/
......
......@@ -186,7 +186,7 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
if ($options['deleted']) {
$instances = field_read_instances(array('object_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
}
else {
$instances = field_info_instances($entity_type, $bundle);
......@@ -616,7 +616,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
foreach ($queried_entities as $entity) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
if ($options['deleted']) {
$instances = field_read_instances(array('object_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_deleted' => $options['deleted']));
}
else {
$instances = field_info_instances($entity_type, $bundle);
......@@ -1188,7 +1188,7 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode = 'full')
* '#title' => the label of the field instance,
* '#label_display' => the label display mode,
* '#object' => the fieldable entity being displayed,
* '#object_type' => the type of the entity being displayed,
* '#entity_type' => the type of the entity being displayed,
* '#language' => the language of the field values being displayed,
* '#view_mode' => the view mode,
* '#field_name' => the name of the field,
......@@ -1233,8 +1233,8 @@ function field_attach_view($entity_type, $entity, $view_mode = 'full', $langcode
// Let other modules alter the renderable array.
$context = array(
'obj_type' => $entity_type,
'object' => $entity,
'entity_type' => $entity_type,
'entity' => $entity,
'view_mode' => $view_mode,
);
drupal_alter('field_attach_view', $output, $context);
......@@ -1278,8 +1278,8 @@ function field_attach_preprocess($entity_type, $entity, $element, &$variables) {
// Let other modules make changes to the $variables array.
$context = array(
'obj_type' => $entity_type,
'object' => $entity,
'entity_type' => $entity_type,
'entity' => $entity,
'element' => $element,
);
drupal_alter('field_attach_preprocess', $variables, $context);
......@@ -1337,7 +1337,7 @@ function field_attach_create_bundle($entity_type, $bundle) {
function field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
db_update('field_config_instance')
->fields(array('bundle' => $bundle_new))
->condition('object_type', $entity_type)
->condition('entity_type', $entity_type)
->condition('bundle', $bundle_old)
->execute();
......
......@@ -45,7 +45,7 @@
* - type (string)
* The type of the field, such as 'text' or 'image'. Field types
* are defined by modules that implement hook_field_info().
* - object_types (array)
* - entity_types (array)
* The array of entity types that can hold instances of this field. If
* empty or not specified, the field can have instances in any entity type.
* - cardinality (integer)
......@@ -108,7 +108,7 @@
* It is populated automatically by field_create_instance().
* - field_name (string)
* The name of the field attached to the bundle by this instance.
* - object_type (string)
* - entity_type (string)
* The name of the entity type the instance is attached to.
* - bundle (string)
* The name of the bundle that the field is attached to.
......@@ -262,13 +262,13 @@ function field_create_field($field) {
// collisions with existing entity properties, but some is better
// than none.
foreach (entity_get_info() as $type => $info) {
if (in_array($field['field_name'], $info['object keys'])) {
if (in_array($field['field_name'], $info['entity keys'])) {
throw new FieldException(t('Attempt to create field name %name which is reserved by entity type %type.', array('%name' => $field['field_name'], '%type' => $type)));
}
}
$field += array(
'object_types' => array(),
'entity_types' => array(),
'cardinality' => 1,
'translatable' => FALSE,
'locked' => FALSE,
......@@ -403,8 +403,8 @@ function field_update_field($field) {
if ($field['type'] != $prior_field['type']) {
throw new FieldException("Cannot change an existing field's type.");
}
if ($field['object_types'] != $prior_field['object_types']) {
throw new FieldException("Cannot change an existing field's object_types property.");
if ($field['entity_types'] != $prior_field['entity_types']) {
throw new FieldException("Cannot change an existing field's entity_types property.");
}
if ($field['storage']['type'] != $prior_field['storage']['type']) {
throw new FieldException("Cannot change an existing field's storage type.");
......@@ -588,7 +588,7 @@ function field_delete_field($field_name) {
* Creates an instance of a field, binding it to a bundle.
*
* @param $instance
* A field instance definition array. The field_name, object_type and
* A field instance definition array. The field_name, entity_type and
* bundle properties are required. Other properties, if omitted,
* will be given the following default values:
* - label: the field name
......@@ -620,15 +620,15 @@ function field_create_instance($instance) {
throw new FieldException(t("Attempt to create an instance of a field @field_name that doesn't exist or is currently inactive.", array('@field_name' => $instance['field_name'])));
}
// Check that the required properties exists.
if (empty($instance['object_type'])) {
if (empty($instance['entity_type'])) {
throw new FieldException(t('Attempt to create an instance of field @field_name without an object type.', array('@field_name' => $instance['field_name'])));
}
if (empty($instance['bundle'])) {
throw new FieldException(t('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $instance['field_name'])));
}
// Check that the field can be attached to this entity type.
if (!empty($field['object_types']) && !in_array($instance['object_type'], $field['object_types'])) {
throw new FieldException(t('Attempt to create an instance of field @field_name on forbidden object type @obj_type.', array('@field_name' => $instance['field_name'], '@obj_type' => $instance['object_type'])));
if (!empty($field['entity_types']) && !in_array($instance['entity_type'], $field['entity_types'])) {
throw new FieldException(t('Attempt to create an instance of field @field_name on forbidden object type @entity_type.', array('@field_name' => $instance['field_name'], '@entity_type' => $instance['entity_type'])));
}
// Set the field id.
......@@ -647,7 +647,7 @@ function field_create_instance($instance) {
// Ensure the field instance is unique within the bundle.
// We only check for instances of active fields, since adding an instance of
// a disabled field is not supported.
$prior_instance = field_read_instance($instance['object_type'], $instance['field_name'], $instance['bundle']);
$prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
if (!empty($prior_instance)) {
$message = t('Attempt to create an instance of field @field_name on bundle @bundle that already has an instance of that field.', array('@field_name' => $instance['field_name'], '@bundle' => $instance['bundle']));
throw new FieldException($message);
......@@ -688,7 +688,7 @@ function field_update_instance($instance) {
// Check that the field instance exists (even if it is inactive, since we
// want to be able to replace inactive widgets with new ones).
$prior_instance = field_read_instance($instance['object_type'], $instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE));
$prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle'], array('include_inactive' => TRUE));
if (empty($prior_instance)) {
throw new FieldException("Attempt to update a field instance that doesn't exist.");
}
......@@ -769,7 +769,7 @@ function _field_write_instance($instance, $update = FALSE) {
$record = array(
'field_id' => $instance['field_id'],
'field_name' => $instance['field_name'],
'object_type' => $instance['object_type'],
'entity_type' => $instance['entity_type'],
'bundle' => $instance['bundle'],
'data' => $data,
'deleted' => $instance['deleted'],
......@@ -810,7 +810,7 @@ function _field_write_instance($instance, $update = FALSE) {
* An instance structure, or FALSE.
*/
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);
$instances = field_read_instances(array('entity_type' => $entity_type, 'field_name' => $field_name, 'bundle' => $bundle), $include_additional);
return $instances ? current($instances) : FALSE;
}
......@@ -858,13 +858,13 @@ function field_read_instances($params = array(), $include_additional = array())
foreach ($results as $record) {
// Filter out instances on unknown entity types (for instance because the
// module exposing them was disabled).
$entity_info = entity_get_info($record['object_type']);
$entity_info = entity_get_info($record['entity_type']);
if ($include_inactive || $entity_info) {
$instance = unserialize($record['data']);
$instance['id'] = $record['id'];
$instance['field_id'] = $record['field_id'];
$instance['field_name'] = $record['field_name'];
$instance['object_type'] = $record['object_type'];
$instance['entity_type'] = $record['entity_type'];
$instance['bundle'] = $record['bundle'];
$instance['deleted'] = $record['deleted'];
......@@ -886,7 +886,7 @@ function field_delete_instance($instance) {
db_update('field_config_instance')
->fields(array('deleted' => 1))
->condition('field_name', $instance['field_name'])
->condition('object_type', $instance['object_type'])
->condition('entity_type', $instance['entity_type'])
->condition('bundle', $instance['bundle'])
->execute();
......
......@@ -203,7 +203,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
'#field_name' => $field['field_name'],
'#field_type' => $field['type'],
'#field_translatable' => $field['translatable'],
'#object_type' => $entity_type,
'#entity_type' => $entity_type,
'#bundle' => $bundle,
'#object' => $entity,
'#items' => $items,
......
......@@ -50,7 +50,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode,
$function = $instance['widget']['module'] . '_field_widget_form';
if (function_exists($function)) {
$element = array(
'#object_type' => $instance['object_type'],
'#entity_type' => $instance['entity_type'],
'#bundle' => $instance['bundle'],
'#field_name' => $field_name,
'#language' => $langcode,
......@@ -161,7 +161,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
for ($delta = 0; $delta <= $max; $delta++) {
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
$element = array(
'#object_type' => $instance['object_type'],
'#entity_type' => $instance['entity_type'],
'#bundle' => $instance['bundle'],
'#field_name' => $field_name,
'#language' => $langcode,
......
......@@ -220,13 +220,13 @@ function _field_info_collate_fields($reset = FALSE) {
foreach ($definitions['instances'] as $instance) {
$field = $info['fields'][$instance['field_name']];
$instance = _field_info_prepare_instance($instance, $field);
$info['instances'][$instance['object_type']][$instance['bundle']][$instance['field_name']] = $instance;
$info['instances'][$instance['entity_type']][$instance['bundle']][$instance['field_name']] = $instance;
// Enrich field definitions with the list of bundles where they have
// instances. NOTE: Deleted fields in $info['field_ids'] are not
// enriched because all of their instances are deleted, too, and
// are thus not in $definitions['instances'].
$info['fields'][$instance['field_name']]['bundles'][$instance['object_type']][] = $instance['bundle'];
$info['field_ids'][$instance['field_id']]['bundles'][$instance['object_type']][] = $instance['bundle'];
$info['fields'][$instance['field_name']]['bundles'][$instance['entity_type']][] = $instance['bundle'];
$info['field_ids'][$instance['field_id']]['bundles'][$instance['entity_type']][] = $instance['bundle'];
}
}
......@@ -291,7 +291,7 @@ function _field_info_prepare_instance($instance, $field) {
}
// Fallback to 'full' display settings for unspecified view modes.
$entity_info = entity_get_info($instance['object_type']);
$entity_info = entity_get_info($instance['entity_type']);
foreach ($entity_info['view modes'] as $view_mode => $info) {
if (!isset($instance['display'][$view_mode])) {
$instance['display'][$view_mode] = $instance['display']['full'];
......
......@@ -130,7 +130,7 @@ function field_schema() {
'not null' => TRUE,
'default' => ''
),
'object_type' => array(
'entity_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
......@@ -158,7 +158,7 @@ function field_schema() {
'primary key' => array('id'),
'indexes' => array(
// Used by field_delete_instance().
'field_name_bundle' => array('field_name', 'object_type', 'bundle'),
'field_name_bundle' => array('field_name', 'entity_type', 'bundle'),
// Used by field_read_instances().
'deleted' => array('deleted'),
),
......
......@@ -608,8 +608,8 @@ function field_view_field($entity_type, $entity, $field_name, $display = array()
// Invoke hook_field_attach_view_alter() to let other modules alter the
// renderable array, as in a full field_attach_view() execution.
$context = array(
'obj_type' => $entity_type,
'object' => $entity,
'entity_type' => $entity_type,
'entity' => $entity,
'view_mode' => '_custom',
);
drupal_alter('field_attach_view', $result, $context);
......
......@@ -577,7 +577,7 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $options)
// If querying all revisions and the entity type has revisions, we need
// to key the results by revision_ids.
$entity_type = entity_get_info($row->type);
$id = ($load_current || empty($entity_type['object keys']['revision'])) ? $row->entity_id : $row->revision_id;
$id = ($load_current || empty($entity_type['entity keys']['revision'])) ? $row->entity_id : $row->revision_id;
if (!isset($return[$row->type][$id])) {
$return[$row->type][$id] = entity_create_stub_entity($row->type, array($row->entity_id, $row->revision_id, $row->bundle));
......@@ -623,7 +623,7 @@ function field_sql_storage_field_storage_delete_revision($entity_type, $entity,
* This function simply marks for deletion all data associated with the field.
*/
function field_sql_storage_field_storage_delete_instance($instance) {
$etid = _field_sql_storage_etid($instance['object_type']);
$etid = _field_sql_storage_etid($instance['entity_type']);
$field = field_info_field($instance['field_name']);
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
......@@ -645,7 +645,7 @@ function field_sql_storage_field_storage_delete_instance($instance) {
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' => $entity_type, 'bundle' => $bundle_new), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
$instances = field_read_instances(array('entity_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') {
......
......@@ -28,7 +28,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$this->field = field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle'
);
$this->instance = field_create_instance($this->instance);
......@@ -303,7 +303,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Create a decimal 5.2 field and add some data.
$field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2));
$field = field_create_field($field);
$instance = array('field_name' => 'decimal52', 'object_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = field_create_instance($instance);
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
$entity->decimal52[LANGUAGE_NONE][0]['value'] = '1.235';
......@@ -329,7 +329,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$field_name = 'testfield';
$field = array('field_name' => $field_name, 'type' => 'text');
$field = field_create_field($field);
$instance = array('field_name' => $field_name, 'object_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = array('field_name' => $field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = field_create_instance($instance);
$tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field));
......@@ -374,7 +374,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Retrieve the field and instance with field_info so the storage details are attached.
$field = field_info_field($this->field['field_name']);
$instance = field_info_instance($this->instance['object_type'], $this->instance['field_name'], $this->instance['bundle']);
$instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']);
// The storage details are indexed by a storage engine type.
$this->assertTrue(array_key_exists('sql', $field['storage']['details']), t('The storage type is SQL.'));
......
......@@ -34,7 +34,7 @@ class ListFieldTestCase extends FieldTestCase {
$this->instance = array(
'field_name' => $this->field_name,
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
......@@ -82,7 +82,7 @@ class ListFieldTestCase extends FieldTestCase {
$this->field = field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
......@@ -184,7 +184,7 @@ class ListFieldUITestCase extends FieldTestCase {
field_create_field($field);
$instance = array(
'field_name' => $field_name,
'object_type' => 'node',
'entity_type' => 'node',
'bundle' => $this->type,
);
field_create_instance($instance);
......
......@@ -61,7 +61,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create an instance of the 'single value' field.
$instance = array(
'field_name' => $this->card_1['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
......@@ -118,7 +118,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create an instance of the 'multiple values' field.
$instance = array(
'field_name' => $this->card_2['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
......@@ -205,7 +205,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create an instance of the 'single value' field.
$instance = array(
'field_name' => $this->card_1['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_select',
......@@ -292,7 +292,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create an instance of the 'multiple values' field.
$instance = array(
'field_name' => $this->card_2['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_select',
......@@ -409,7 +409,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Create an instance of the 'boolean' field.
$instance = array(
'field_name' => $this->bool['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_onoff',
......
......@@ -40,7 +40,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field['field_name'],
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'text_textfield',
......@@ -86,7 +86,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'label' => $this->randomName() . '_label',
'settings' => array(
......@@ -140,7 +140,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'object_type' => 'test_entity',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'label' => $this->randomName() . '_label',
'settings' => array(
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ function field_test_entity_info() {
return array(
'test_entity' => array(
'name' => t('Test Entity'),
'object keys' => array(
'entity keys' => array(
'id' => 'ftid',
'revision' => 'ftvid',
'bundle' => 'fttype',
......@@ -36,7 +36,7 @@ function field_test_entity_info() {
// This entity type doesn't get form handling for now...
'test_cacheable_entity' => array(
'name' => t('Test Entity, cacheable'),
'object keys' => array(
'entity keys' => array(
'id' => 'ftid',
'revision' => 'ftvid',
'bundle' => 'fttype',
......
......@@ -323,7 +323,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor
// If querying all revisions and the entity type has revisions, we need
// to key the results by revision_ids.
$entity_type = entity_get_info($row->type);
$id = ($load_current || empty($entity_type['object keys']['revision'])) ? $row->entity_id : $row->revision_id;
$id = ($load_current || empty($entity_type['entity keys']['revision'])) ? $row->entity_id : $row->revision_id;
if (!isset($return[$row->type][$id])) {
$return[$row->type][$id] = entity_create_stub_entity($row->type, array($row->entity_id, $row->revision_id, $row->bundle));
......
......@@ -90,7 +90,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle
$form += array(
'#tree' => TRUE,
'#object_type' => $entity_type,
'#entity_type' => $entity_type,
'#bundle' => $bundle,
'#fields' => array_keys($instances),
'#extra' => array_keys($extra),
......@@ -289,9 +289,9 @@ function template_preprocess_field_ui_field_overview_form(&$vars) {
drupal_add_js(drupal_get_path('module', 'field_ui') . '/field_ui.js');
// Add settings for the update selects behavior.
$js_fields = array();
foreach (field_ui_existing_field_options($form['#object_type'], $form['#bundle']) as $field_name => $fields) {
foreach (field_ui_existing_field_options($form['#entity_type'], $form['#bundle']) as $field_name => $fields) {
$field = field_info_field($field_name);
$instance = field_info_instance($form['#object_type'], $field_name, $form['#bundle']);
$instance = field_info_instance($form['#entity_type'], $field_name, $form['#bundle']);
$js_fields[$field_name] = array('label' => $instance['label'], 'type' => $field['type'], 'widget' => $instance['widget']['type']);
}
drupal_add_js(array('fieldWidgetTypes' => field_ui_widget_type_options(), 'fields' => $js_fields), 'setting');
......@@ -459,7 +459,7 @@ function _field_ui_field_overview_form_validate_add_existing($form, &$form_state
*/
function field_ui_field_overview_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$entity_type = $form['#object_type'];
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
......@@ -497,7 +497,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) {
);
$instance = array(
'field_name' => $field['field_name'],
'object_type' => $entity_type,
'entity_type' => $entity_type,
'bundle' => $bundle,
'label' => $values['label'],
'widget' => array(
......@@ -532,7 +532,7 @@ function field_ui_field_overview_form_submit($form, &$form_state) {
else {
$instance = array(
'field_name' => $field['field_name'],
'object_type' => $entity_type,
'entity_type' => $entity_type,
'bundle' => $bundle,
'label' => $values['label'],
'widget' => array(
......@@ -580,7 +580,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
$form += array(
'#tree' => TRUE,
'#object_type' => $entity_type,
'#entity_type' => $entity_type,
'#bundle' => $bundle,
'#fields' => array_keys($instances),
'#contexts' => $view_modes_selector,
......@@ -635,8 +635,8 @@ function template_preprocess_field_ui_display_overview_form(&$vars) {
$form = &$vars['form'];
$contexts_selector = $form['#contexts'];
$view_modes = field_ui_view_modes_tabs($form['#object_type'], $contexts_selector);
$entity_info = entity_get_info($form['#object_type']);
$view_modes = field_ui_view_modes_tabs($form['#entity_type'], $contexts_selector);
$entity_info = entity_get_info($form['#entity_type']);
$view_modes_info = $entity_info['view modes'];
$vars['contexts'] = array();
foreach ($view_modes as $view_mode) {
......@@ -677,7 +677,7 @@ function field_ui_display_overview_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
foreach ($form_values as $key => $values) {
if (in_array($key, $form['#fields'])) {
$instance = field_info_instance($form['#object_type'], $key, $form['#bundle']);
$instance = field_info_instance($form['#entity_type'], $key, $form['#bundle']);
foreach ($instance['display'] as $view_mode => $display) {
if (isset($values[$view_mode])) {
$instance['display'][$view_mode] = array_merge($instance['display'][$view_mode], $values[$view_mode]);
......@@ -793,7 +793,7 @@ function field_ui_existing_field_options($entity_type, $bundle) {
// - field that cannot be added to the entity type.
if (empty($field['locked'])
&& !field_info_instance($entity_type, $field['field_name'], $bundle)
&& (empty($field['object_types']) || in_array($entity_type, $field['object_types']))) {
&& (empty($field['entity_types']) || in_array($entity_type, $field['entity_types']))) {
$text = t('@type: @field (@label)', array(
'@type' => $field_types[$field['type']]['label'],
'@label' => t($instance['label']), '@field' => $instance['field_name'],
......@@ -860,7 +860,7 @@ function field_ui_field_settings_form($form, &$form_state, $entity_type, $bundle
'#markup' => t('%field has no field settings.', array('%field' => $instance['label'])),
);
}
$form['#object_type'] = $entity_type;
$form['#entity_type'] = $entity_type;
$form['#bundle'] = $bundle;
$form['actions'] = array('#type' => 'container', '#attributes' => array('class' => array('form-actions')));
......@@ -878,7 +878,7 @@ function field_ui_field_settings_form_submit($form, &$form_state) {
// Merge incoming form values into the existing field.
$field = field_info_field($field_values['field_name']);
$entity_type = $form['#object_type'];
$entity_type = $form['#entity_type'];
$bundle = $form['#bundle'];
$instance = field_info_instance($entity_type, $field['field_name'], $bundle