#707724 follow-up by yched: Fix more confusing field/entity api arguments.
parent
f86fda29a3
commit
7d4b84b878
|
@ -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 @@ class DrupalDefaultEntityController implements DrupalEntityControllerInterface {
|
|||
$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(
|
||||
|
|
|
@ -78,7 +78,7 @@ class FieldAttachTestCase extends FieldTestCase {
|
|||
$this->field_id = $this->field['id'];
|
||||
$this->instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
|
@ -207,7 +207,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
|
|||
foreach ($field_bundles_map[$i] as $bundle) {
|
||||
$instance = array(
|
||||
'field_name' => $field_names[$i],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => $bundles[$bundle],
|
||||
'settings' => array(
|
||||
// Configure the instance so that we test hook_field_load()
|
||||
|
@ -278,7 +278,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
|
|||
field_create_field($field);
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
@ -319,13 +319,13 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
|
|||
$field = field_create_field($field);
|
||||
$instance = array(
|
||||
'field_name' => $field_name,
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
||||
$field = field_info_field($instance['field_name']);
|
||||
$instance = field_info_instance($instance['object_type'], $instance['field_name'], $instance['bundle']);
|
||||
$instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
|
||||
|
||||
// The storage details are indexed by a storage engine type.
|
||||
$this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), t('The storage type is Drupal variables.'));
|
||||
|
@ -570,7 +570,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
|
|||
field_create_field($field);
|
||||
$instance = array(
|
||||
'field_name' => $field_name,
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => $this->instance['bundle'],
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
|
@ -626,10 +626,10 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
|
|||
|
||||
// Create instances of both fields on the second entity type.
|
||||
$instance = $this->instance;
|
||||
$instance['object_type'] = 'test_cacheable_entity';
|
||||
$instance['entity_type'] = 'test_cacheable_entity';
|
||||
field_create_instance($instance);
|
||||
$instance2 = $this->instance2;
|
||||
$instance2['object_type'] = 'test_cacheable_entity';
|
||||
$instance2['entity_type'] = 'test_cacheable_entity';
|
||||
field_create_instance($instance2);
|
||||
|
||||
// Unconditional count query returns 0.
|
||||
|
@ -990,7 +990,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase {
|
|||
$entity_type = 'test_cacheable_entity';
|
||||
$cid = "field:$entity_type:{$entity_init->ftid}";
|
||||
$instance = $this->instance;
|
||||
$instance['object_type'] = $entity_type;
|
||||
$instance['entity_type'] = $entity_type;
|
||||
field_create_instance($instance);
|
||||
|
||||
// Check that no initial cache entry is present.
|
||||
|
@ -1247,7 +1247,7 @@ class FieldInfoTestCase extends FieldTestCase {
|
|||
// Create an instance, verify that it shows up
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'label' => $this->randomName(),
|
||||
'description' => $this->randomName(),
|
||||
|
@ -1306,7 +1306,7 @@ class FieldInfoTestCase extends FieldTestCase {
|
|||
field_create_field($field_definition);
|
||||
$instance_definition = array(
|
||||
'field_name' => $field_definition['field_name'],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance_definition);
|
||||
|
@ -1330,7 +1330,7 @@ class FieldInfoTestCase extends FieldTestCase {
|
|||
field_cache_clear();
|
||||
|
||||
// Read the instance back.
|
||||
$instance = field_info_instance($instance_definition['object_type'], $instance_definition['field_name'], $instance_definition['bundle']);
|
||||
$instance = field_info_instance($instance_definition['entity_type'], $instance_definition['field_name'], $instance_definition['bundle']);
|
||||
|
||||
// Check that all expected instance settings are in place.
|
||||
$field_type = field_info_field_types($field_definition['type']);
|
||||
|
@ -1363,7 +1363,7 @@ class FieldInfoTestCase extends FieldTestCase {
|
|||
field_create_field($field_definition);
|
||||
$instance_definition = array(
|
||||
'field_name' => 'field',
|
||||
'object_type' => 'comment',
|
||||
'entity_type' => 'comment',
|
||||
'bundle' => 'comment_node_article',
|
||||
);
|
||||
field_create_instance($instance_definition);
|
||||
|
@ -1415,7 +1415,7 @@ class FieldFormTestCase extends FieldTestCase {
|
|||
$this->field_unlimited = array('field_name' => drupal_strtolower($this->randomName()), 'type' => 'test_field', 'cardinality' => FIELD_CARDINALITY_UNLIMITED);
|
||||
|
||||
$this->instance = array(
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'label' => $this->randomName() . '_label',
|
||||
'description' => $this->randomName() . '_description',
|
||||
|
@ -1711,7 +1711,7 @@ class FieldFormTestCase extends FieldTestCase {
|
|||
$field_name_no_access = $field_no_access['field_name'];
|
||||
$instance_no_access = array(
|
||||
'field_name' => $field_name_no_access,
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'default_value' => array(0 => array('value' => 99)),
|
||||
);
|
||||
|
@ -1775,7 +1775,7 @@ class FieldDisplayAPITestCase extends FieldTestCase {
|
|||
);
|
||||
$this->instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'label' => $this->label,
|
||||
'display' => array(
|
||||
|
@ -2173,7 +2173,7 @@ class FieldCrudTestCase extends FieldTestCase {
|
|||
// Create instances for each.
|
||||
$this->instance_definition = array(
|
||||
'field_name' => $this->field['field_name'],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
'widget' => array(
|
||||
'type' => 'test_field_widget',
|
||||
|
@ -2271,7 +2271,7 @@ class FieldCrudTestCase extends FieldTestCase {
|
|||
// Create a decimal 5.2 field.
|
||||
$field = array('field_name' => 'decimal53', 'type' => 'number_decimal', 'cardinality' => 3, 'settings' => array('precision' => 5, 'scale' => 2));
|
||||
$field = field_create_field($field);
|
||||
$instance = array('field_name' => 'decimal53', 'object_type' => 'test_entity', 'bundle' => 'test_bundle');
|
||||
$instance = array('field_name' => 'decimal53', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
|
||||
$instance = field_create_instance($instance);
|
||||
|
||||
// Update it to a deciaml 5.3 field.
|
||||
|
@ -2402,7 +2402,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase {
|
|||
field_create_field($this->field);
|
||||
$this->instance_definition = array(
|
||||
'field_name' => $this->field['field_name'],
|
||||
'object_type' => 'test_entity',
|
||||
'entity_type' => 'test_entity',
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
}
|
||||
|
@ -2464,7 +2464,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase {
|
|||
$field_restricted = array(
|
||||
'field_name' => drupal_strtolower($this->randomName()),
|
||||
'type' => 'test_field',
|
||||
'object_types' => array('test_cacheable_entity'),
|
||||
'entity_types' => array('test_cacheable_entity'),
|
||||
);
|
||||
field_create_field($field_restricted);
|
||||
|
||||
|
@ -2473,7 +2473,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase {
|
|||
try {
|
||||
$instance = $this->instance_definition;
|
||||
$instance['field_name'] = $field_restricted['field_name'];
|
||||
$instance['object_type'] = 'test_cacheable_entity';
|
||||
$instance['entity_type'] = 'test_cacheable_entity';
|
||||
field_create_instance($instance);
|
||||
$this->pass(t('Can create an instance on an entity type allowed by the field.'));
|
||||
}
|
||||
|
@ -2620,7 +2620,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
|
||||
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
|
||||
|
||||
$this->obj_type = 'test_entity';
|
||||
$this->entity_type = 'test_entity';
|
||||
|
||||
$field = array(
|
||||
'field_name' => $this->field_name,
|
||||
|
@ -2633,7 +2633,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => $this->field_name,
|
||||
'object_type' => $this->obj_type,
|
||||
'entity_type' => $this->entity_type,
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
@ -2660,7 +2660,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
// Test hook_field_languages() invocation on a translatable field.
|
||||
variable_set('field_test_field_available_languages_alter', TRUE);
|
||||
$enabled_languages = field_content_languages();
|
||||
$available_languages = field_available_languages($this->obj_type, $this->field);
|
||||
$available_languages = field_available_languages($this->entity_type, $this->field);
|
||||
foreach ($available_languages as $delta => $langcode) {
|
||||
if ($langcode != 'xx' && $langcode != 'en') {
|
||||
$this->assertTrue(in_array($langcode, $enabled_languages), t('%language is an enabled language.', array('%language' => $langcode)));
|
||||
|
@ -2672,7 +2672,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
// Test field_available_languages() behavior for untranslatable fields.
|
||||
$this->field['translatable'] = FALSE;
|
||||
$this->field_name = $this->field['field_name'] = $this->instance['field_name'] = drupal_strtolower($this->randomName() . '_field_name');
|
||||
$available_languages = field_available_languages($this->obj_type, $this->field);
|
||||
$available_languages = field_available_languages($this->entity_type, $this->field);
|
||||
$this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, t('For untranslatable fields only LANGUAGE_NONE is available.'));
|
||||
}
|
||||
|
||||
|
@ -2687,7 +2687,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
// the result of field_available_languages().
|
||||
$values = array();
|
||||
$extra_languages = mt_rand(1, 4);
|
||||
$languages = $available_languages = field_available_languages($this->obj_type, $this->field);
|
||||
$languages = $available_languages = field_available_languages($this->entity_type, $this->field);
|
||||
for ($i = 0; $i < $extra_languages; ++$i) {
|
||||
$languages[] = $this->randomString(2);
|
||||
}
|
||||
|
@ -2718,7 +2718,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
$entities = array();
|
||||
$entity_type = 'test_entity';
|
||||
$entity_count = mt_rand(1, 5);
|
||||
$available_languages = field_available_languages($this->obj_type, $this->field);
|
||||
$available_languages = field_available_languages($this->entity_type, $this->field);
|
||||
|
||||
for ($id = 1; $id <= $entity_count; ++$id) {
|
||||
$entity = field_test_create_stub_entity($id, $id, $this->instance['bundle']);
|
||||
|
@ -2809,7 +2809,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => $entity_type,
|
||||
'entity_type' => $entity_type,
|
||||
'bundle' => 'test_bundle',
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
@ -2938,7 +2938,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase {
|
|||
foreach ($this->fields as $field) {
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => $this->entity_type,
|
||||
'entity_type' => $this->entity_type,
|
||||
'bundle' => $bundle,
|
||||
'widget' => array(
|
||||
'type' => 'test_field_widget',
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -940,7 +940,7 @@ function field_ui_widget_type_form_submit($form, &$form_state) {
|
|||
$form_values = $form_state['values'];
|
||||
$instance = $form['#instance'];
|
||||
$bundle = $instance['bundle'];
|
||||
$entity_type = $instance['object_type'];
|
||||
$entity_type = $instance['entity_type'];
|
||||
|
||||
// Set the right module information.
|
||||
$widget_type = field_info_widget_types($form_values['widget_type']);
|
||||
|
@ -967,7 +967,7 @@ function field_ui_field_delete_form($form, &$form_state, $entity_type, $bundle,
|
|||
$instance = field_info_instance($entity_type, $field['field_name'], $bundle);
|
||||
$admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
|
||||
|
||||
$form['object_type'] = array('#type' => 'value', '#value' => $entity_type);
|
||||
$form['entity_type'] = array('#type' => 'value', '#value' => $entity_type);
|
||||
$form['bundle'] = array('#type' => 'value', '#value' => $bundle);
|
||||
$form['field_name'] = array('#type' => 'value', '#value' => $field['field_name']);
|
||||
|
||||
|
@ -994,7 +994,7 @@ function field_ui_field_delete_form_submit($form, &$form_state) {
|
|||
$form_values = $form_state['values'];
|
||||
$field_name = $form_values['field_name'];
|
||||
$bundle = $form_values['bundle'];
|
||||
$entity_type = $form_values['object_type'];
|
||||
$entity_type = $form_values['entity_type'];
|
||||
|
||||
$field = field_info_field($field_name);
|
||||
$instance = field_info_instance($entity_type, $field_name, $bundle);
|
||||
|
@ -1054,7 +1054,7 @@ function field_ui_field_edit_form($form, &$form_state, $entity_type, $bundle, $f
|
|||
'#type' => 'value',
|
||||
'#value' => $instance['field_name'],
|
||||
);
|
||||
$form['instance']['object_type'] = array(
|
||||
$form['instance']['entity_type'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => $entity_type,
|
||||
);
|
||||
|
@ -1262,13 +1262,13 @@ function field_ui_field_edit_form_submit($form, &$form_state) {
|
|||
$instance['default_value'] = $items ? $items : NULL;
|
||||
|
||||
// Update the instance settings.
|
||||
$instance_source = field_info_instance($instance['object_type'], $instance['field_name'], $instance['bundle']);
|
||||
$instance_source = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
|
||||
$instance = array_merge($instance_source, $instance);
|
||||
field_update_instance($instance);
|
||||
|
||||
drupal_set_message(t('Saved %label configuration.', array('%label' => $instance['label'])));
|
||||
|
||||
$form_state['redirect'] = field_ui_next_destination($instance['object_type'], $instance['bundle']);
|
||||
$form_state['redirect'] = field_ui_next_destination($instance['entity_type'], $instance['bundle']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -300,7 +300,7 @@ function field_ui_inactive_instances($entity_type, $bundle_name = NULL) {
|
|||
$inactive = array();
|
||||
$params = array();
|
||||
}
|
||||
$params['object_type'] = $entity_type;
|
||||
$params['entity_type'] = $entity_type;
|
||||
|
||||
$active_instances = field_info_instances($entity_type);
|
||||
$all_instances = field_read_instances($params, array('include_inactive' => TRUE));
|
||||
|
|
|
@ -179,7 +179,7 @@ class FieldUITestCase extends DrupalWebTestCase {
|
|||
field_create_field($field);
|
||||
$instance = array(
|
||||
'field_name' => $field_name,
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => $this->type,
|
||||
);
|
||||
field_create_instance($instance);
|
||||
|
|
|
@ -246,7 +246,7 @@ function file_field_prepare_view($entity_type, $entities, $field, $instances, $l
|
|||
/**
|
||||
* Implements hook_field_presave().
|
||||
*/
|
||||
function file_field_presave($obj_type, $object, $field, $instance, $langcode, &$items) {
|
||||
function file_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
|
||||
// Make sure that each file which will be saved with this object has a
|
||||
// permanent status, so that it will not be removed when temporary files are
|
||||
// cleaned up.
|
||||
|
|
|
@ -915,7 +915,7 @@ function file_get_file_reference_count($file, $field = NULL, $field_type = NULL)
|
|||
if (isset($file->file_field_type) && isset($file->file_field_id)) {
|
||||
if ($file->file_field_type == $entity_type) {
|
||||
$info = entity_get_info($entity_type);
|
||||
$id = $types[$entity_type]['object keys']['id'];
|
||||
$id = $types[$entity_type]['entity keys']['id'];
|
||||
foreach ($type_references as $reference) {
|
||||
if ($file->file_field_id == $reference->$id) {
|
||||
$reference_count--;
|
||||
|
|
|
@ -57,7 +57,7 @@ class FileFieldTestCase extends DrupalWebTestCase {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'label' => $name,
|
||||
'bundle' => $type_name,
|
||||
'required' => !empty($instance_settings['required']),
|
||||
|
|
|
@ -55,7 +55,7 @@ function forum_enable() {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'label' => $vocabulary->name,
|
||||
'bundle' => 'forum',
|
||||
'widget' => array(
|
||||
|
|
|
@ -228,8 +228,8 @@ function image_field_prepare_view($entity_type, $entities, $field, $instances, $
|
|||
/**
|
||||
* Implements hook_field_presave().
|
||||
*/
|
||||
function image_field_presave($obj_type, $object, $field, $instance, $langcode, &$items) {
|
||||
file_field_presave($obj_type, $object, $field, $instance, $langcode, $items);
|
||||
function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
|
||||
file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -543,7 +543,7 @@ class ImageFieldTestCase extends DrupalWebTestCase {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => $field['field_name'],
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'label' => $name,
|
||||
'bundle' => $type_name,
|
||||
'required' => !empty($instance_settings['required']),
|
||||
|
|
|
@ -183,7 +183,7 @@ function node_entity_info() {
|
|||
'revision table' => 'node_revision',
|
||||
'uri callback' => 'node_uri',
|
||||
'fieldable' => TRUE,
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'nid',
|
||||
'revision' => 'vid',
|
||||
'bundle' => 'type',
|
||||
|
@ -563,7 +563,7 @@ function node_configure_fields($type) {
|
|||
$field = array(
|
||||
'field_name' => 'body',
|
||||
'type' => 'text_with_summary',
|
||||
'object_types' => array('node'),
|
||||
'entity_types' => array('node'),
|
||||
'translatable' => TRUE,
|
||||
);
|
||||
$field = field_create_field($field);
|
||||
|
@ -571,7 +571,7 @@ function node_configure_fields($type) {
|
|||
if (empty($instance)) {
|
||||
$instance = array(
|
||||
'field_name' => 'body',
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => $type->type,
|
||||
'label' => $type->body_label,
|
||||
'widget_type' => 'text_textarea_with_summary',
|
||||
|
|
|
@ -507,7 +507,7 @@ function rdf_preprocess_node(&$variables) {
|
|||
*/
|
||||
function rdf_preprocess_field(&$variables) {
|
||||
$element = $variables['element'];
|
||||
$mapping = rdf_mapping_load($element['#object_type'], $element['#bundle']);
|
||||
$mapping = rdf_mapping_load($element['#entity_type'], $element['#bundle']);
|
||||
$field_name = $element['#field_name'];
|
||||
|
||||
if (!empty($mapping) && !empty($mapping[$field_name])) {
|
||||
|
|
|
@ -946,7 +946,7 @@ class FormsArbitraryRebuildTestCase extends DrupalWebTestCase {
|
|||
field_create_field($field);
|
||||
|
||||
$instance = array(
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'test_multiple',
|
||||
'bundle' => 'page',
|
||||
'label' => 'Test a multiple valued field',
|
||||
|
|
|
@ -70,7 +70,7 @@ function hook_hook_info() {
|
|||
* uri elements of the entity, e.g. 'path' and 'options'. The actual entity
|
||||
* uri can be constructed by passing these elements to url().
|
||||
* - fieldable: Set to TRUE if you want your entity type to be fieldable.
|
||||
* - object keys: An array describing how the Field API can extract the
|
||||
* - entity keys: An array describing how the Field API can extract the
|
||||
* information it needs from the objects of the type. Elements:
|
||||
* - id: The name of the property that contains the primary id of the
|
||||
* object. Every object passed to the Field API must have this property
|
||||
|
@ -97,7 +97,7 @@ function hook_hook_info() {
|
|||
* field_attach_load().
|
||||
* - bundles: An array describing all bundles for this object type.
|
||||
* Keys are bundles machine names, as found in the objects' 'bundle'
|
||||
* property (defined in the 'object keys' entry above). Elements:
|
||||
* property (defined in the 'entity keys' entry above). Elements:
|
||||
* - label: The human-readable name of the bundle.
|
||||
* - admin: An array of information that allows Field UI pages to attach
|
||||
* themselves to the existing administration pages for the bundle.
|
||||
|
@ -131,7 +131,7 @@ function hook_entity_info() {
|
|||
'revision table' => 'node_revision',
|
||||
'path callback' => 'node_path',
|
||||
'fieldable' => TRUE,
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'nid',
|
||||
'revision' => 'vid',
|
||||
'bundle' => 'type',
|
||||
|
@ -1425,7 +1425,7 @@ function hook_mail($key, &$message, $params) {
|
|||
'%username' => format_username($account),
|
||||
);
|
||||
if ($context['hook'] == 'taxonomy') {
|
||||
$entity = $params['object'];
|
||||
$entity = $params['entity'];
|
||||
$vocabulary = taxonomy_vocabulary_load($entity->vid);
|
||||
$variables += array(
|
||||
'%term_name' => $entity->name,
|
||||
|
|
|
@ -47,14 +47,14 @@ define('DRUPAL_OPTIONAL', 1);
|
|||
define('DRUPAL_REQUIRED', 2);
|
||||
|
||||
/**
|
||||
* Return only visible regions.
|
||||
* Return only visible regions.
|
||||
*
|
||||
* @see system_region_list()
|
||||
*/
|
||||
define('REGIONS_VISIBLE', 'visible');
|
||||
|
||||
/**
|
||||
* Return all regions.
|
||||
* Return all regions.
|
||||
*
|
||||
* @see system_region_list()
|
||||
*/
|
||||
|
@ -261,7 +261,7 @@ function system_entity_info() {
|
|||
'file' => array(
|
||||
'label' => t('File'),
|
||||
'base table' => 'file',
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'fid',
|
||||
),
|
||||
'static cache' => FALSE,
|
||||
|
|
|
@ -365,7 +365,7 @@ function taxonomy_update_7004() {
|
|||
'label' => $vocabulary->name,
|
||||
'field_name' => $field_name,
|
||||
'bundle' => $bundle,
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'description' => $vocabulary->help,
|
||||
'widget' => array(
|
||||
'type' => $vocabulary->tags ? 'taxonomy_autocomplete' : 'select',
|
||||
|
|
|
@ -89,7 +89,7 @@ function taxonomy_entity_info() {
|
|||
'base table' => 'taxonomy_term_data',
|
||||
'uri callback' => 'taxonomy_term_uri',
|
||||
'fieldable' => TRUE,
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'tid',
|
||||
'bundle' => 'vocabulary_machine_name',
|
||||
),
|
||||
|
@ -120,7 +120,7 @@ function taxonomy_entity_info() {
|
|||
'label' => t('Taxonomy vocabulary'),
|
||||
'controller class' => 'TaxonomyVocabularyController',
|
||||
'base table' => 'taxonomy_vocabulary',
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'vid',
|
||||
),
|
||||
'fieldable' => FALSE,
|
||||
|
|
|
@ -342,7 +342,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
|
|||
$this->instance = array(
|
||||
'field_name' => 'taxonomy_' . $this->vocabulary->machine_name,
|
||||
'bundle' => 'article',
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'widget' => array(
|
||||
'type' => 'options_select',
|
||||
),
|
||||
|
@ -761,7 +761,7 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
|
|||
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_select',
|
||||
|
@ -821,7 +821,7 @@ class TaxonomyTermFieldTestCase extends TaxonomyWebTestCase {
|
|||
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',
|
||||
'widget' => array(
|
||||
|
@ -894,7 +894,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase {
|
|||
$this->instance = array(
|
||||
'field_name' => 'taxonomy_' . $this->vocabulary->machine_name,
|
||||
'bundle' => 'article',
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'widget' => array(
|
||||
'type' => 'options_select',
|
||||
),
|
||||
|
|
|
@ -131,7 +131,7 @@ function user_entity_info() {
|
|||
'base table' => 'users',
|
||||
'uri callback' => 'user_uri',
|
||||
'fieldable' => TRUE,
|
||||
'object keys' => array(
|
||||
'entity keys' => array(
|
||||
'id' => 'uid',
|
||||
),
|
||||
'bundles' => array(
|
||||
|
|
|
@ -301,7 +301,7 @@ function standard_install() {
|
|||
|
||||
$instance = array(
|
||||
'field_name' => 'taxonomy_' . $vocabulary->machine_name,
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'label' => $vocabulary->name,
|
||||
'bundle' => 'article',
|
||||
'description' => $vocabulary->help,
|
||||
|
@ -340,7 +340,7 @@ function standard_install() {
|
|||
// See http://api.drupal.org/api/function/field_create_instance/7
|
||||
$instance = array(
|
||||
'field_name' => 'field_image',
|
||||
'object_type' => 'node',
|
||||
'entity_type' => 'node',
|
||||
'label' => 'Image',
|
||||
'bundle' => 'article',
|
||||
'description' => 'Upload an image to go with this article.',
|
||||
|
|
Loading…
Reference in New Issue