Переглянути джерело

Renamed 'entity_id' to 'id'

Stephen Ficklin 9 роки тому
батько
коміт
2797d5c53f

+ 11 - 11
tripal_entities/api/tripal_entities.api.inc

@@ -33,7 +33,7 @@ function tripal_data_get_types($type_name = NULL) {
  * Fetch a tripal_data object. Make sure that the wildcard you choose
  * in the tripal_data entity definition fits the function name here.
  *
- * @param $entity_id
+ * @param $id
  *   Integer specifying the tripal_data id.
  * @param $reset
  *   A boolean indicating that the internal cache should be reset.
@@ -42,8 +42,8 @@ function tripal_data_get_types($type_name = NULL) {
  *
  * @see tripal_data_load_multiple()
  */
-function tripal_data_load($entity_id, $reset = FALSE) {
-  $tripal_datas = tripal_data_load_multiple(array($entity_id), array(), $reset);
+function tripal_data_load($id, $reset = FALSE) {
+  $tripal_datas = tripal_data_load_multiple(array($id), array(), $reset);
   return reset($tripal_datas);
 }
 
@@ -51,20 +51,20 @@ function tripal_data_load($entity_id, $reset = FALSE) {
 /**
  * Load multiple tripal_datas based on certain conditions.
  *
- * @param $entity_ids
+ * @param $ids
  *   An array of tripal_data IDs.
  * @param $conditions
  *   An array of conditions to match against the entity table.
  * @param $reset
  *   A boolean indicating that the internal cache should be reset.
  * @return
- *   An array of tripal_data objects, indexed by entity_id.
+ *   An array of tripal_data objects, indexed by id.
  *
  * @see entity_load()
  * @see tripal_data_load()
  */
-function tripal_data_load_multiple($entity_ids = array(), $conditions = array(), $reset = FALSE) {
-  return entity_load('tripal_data', $entity_ids, $conditions, $reset);
+function tripal_data_load_multiple($ids = array(), $conditions = array(), $reset = FALSE) {
+  return entity_load('tripal_data', $ids, $conditions, $reset);
 }
 
 
@@ -79,11 +79,11 @@ function tripal_data_delete(TripalData $tripal_data) {
 /**
  * Delete multiple tripal_datas.
  *
- * @param $entity_ids
+ * @param $ids
  *   An array of tripal_data IDs.
  */
-function tripal_data_delete_multiple(array $entity_ids) {
-  entity_get_controller('tripal_data')->delete($entity_ids);
+function tripal_data_delete_multiple(array $ids) {
+  entity_get_controller('tripal_data')->delete($ids);
 }
 
 
@@ -129,7 +129,7 @@ function tripal_data_type_delete(TripalDataType $type) {
  */
 function tripal_data_uri(TripalData $entity){
   return array(
-    'path' => 'data/' . $entity->entity_id,
+    'path' => 'data/' . $entity->id,
   );
 }
 

+ 7 - 7
tripal_entities/includes/TripalDataController.inc

@@ -25,7 +25,7 @@ class TripalDataController extends EntityAPIController {
   public function create(array $values = array()) {
     // Add values that are specific to our entity
     $values += array(
-      'entity_id' => '',
+      'id' => '',
       'title' => '',
       'created' => '',
       'changed' => '',
@@ -53,7 +53,7 @@ class TripalDataController extends EntityAPIController {
    *   An array of entity IDs or a single numeric ID.
    */
   public function deleteMultiple($entities) {
-    $entity_ids = array();
+    $ids = array();
     if (!empty($entities)) {
       $transaction = db_transaction();
       try {
@@ -61,10 +61,10 @@ class TripalDataController extends EntityAPIController {
           // Invoke hook_entity_delete().
           module_invoke_all('entity_delete', $entity, 'tripal_data');
           field_attach_delete('tripal_data', $entity);
-          $entity_ids[] = $entity->entity_id;
+          $ids[] = $entity->id;
         }
         db_delete('tripal_data')
-        ->condition('entity_id', $entity_ids, 'IN')
+        ->condition('id', $ids, 'IN')
         ->execute();
       }
       catch (Exception $e) {
@@ -81,9 +81,9 @@ class TripalDataController extends EntityAPIController {
   public function save($entity) {
     global $user;
 
-    // If our entity has no entity_id, then we need to give it a
+    // If our entity has no id, then we need to give it a
     // time of creation.
-    if (empty($entity->entity_id)) {
+    if (empty($entity->id)) {
       $entity->created = time();
       $invocation = 'entity_insert';
     }
@@ -121,7 +121,7 @@ class TripalDataController extends EntityAPIController {
     );
     $success = drupal_write_record('tripal_data', $record);
     if ($success == SAVED_NEW) {
-      $entity->entity_id = $record['entity_id'];
+      $entity->id = $record['id'];
     }
 
     // Invoke either hook_entity_update() or hook_entity_insert().

+ 5 - 5
tripal_entities/includes/TripalDataUIController.inc

@@ -147,7 +147,7 @@ function tripal_data_form($form, &$form_state, $entity = NULL) {
   // Set defaults if an entity was provided.
   if ($entity) {
     drupal_set_title('Edit ' . $entity->title);
-    $entity_id = $entity->entity_id;
+    $id = $entity->id;
     $values = array('cvterm_id' => $entity->cvterm_id);
     $cvterm = chado_generate_var('cvterm', $values);
     $cv_id = $cvterm->cv_id->cv_id;
@@ -379,9 +379,9 @@ function tripal_data_form_validate($form, &$form_state) {
  */
 function tripal_data_form_submit($form, &$form_state) {
   if ($form_state['clicked_button']['#name'] == 'cancel') {
-    if (array_key_exists('entity_id', $form_state['values'])){
+    if (array_key_exists('id', $form_state['values'])){
       $entity = $form_state['values']['entity'];
-      $form_state['redirect'] = "data/$entity->entity_id";
+      $form_state['redirect'] = "data/$entity->id";
     }
     else {
       $form_state['redirect'] = "admin/structure/tripal_data";
@@ -398,7 +398,7 @@ function tripal_data_form_submit($form, &$form_state) {
     // attach the fields and save.
     $entity = entity_ui_controller('tripal_data')->entityFormSubmitBuildEntity($form, $form_state);
     $entity->save();
-    $form_state['redirect'] = "data/$entity->entity_id";
+    $form_state['redirect'] = "data/$entity->id";
   }
 }
 /**
@@ -476,7 +476,7 @@ function tripal_data_set_breadcrumb() {
  */
 function tripal_data_view($entity, $view_mode = 'full') {
   $controller = entity_get_controller('tripal_data');
-  $content = $controller->view(array($entity->entity_id => $entity));
+  $content = $controller->view(array($entity->id => $entity));
   drupal_set_title($entity->title);
   return $content;
 }

+ 2 - 3
tripal_entities/includes/tripal_entities.admin.inc

@@ -279,7 +279,7 @@ function tripal_entities_add_bundle_fields($tablename, $entity_type_name, $bundl
         $settings['max_length'] = '';
         break;
       case 'blob':
-        // not sure how to support a blobl field.
+        // not sure how to support a blob field.
         continue;
         break;
       case 'int':
@@ -298,7 +298,7 @@ function tripal_entities_add_bundle_fields($tablename, $entity_type_name, $bundl
         $widget_type = 'number';
         break;
       case 'serial':
-        // Serial fields are not every added as fields.
+        // Serial fields are most likely not needed as a field.
         break;
       case 'boolean':
         // TODO: what is the proper field for booleans?????
@@ -326,7 +326,6 @@ function tripal_entities_add_bundle_fields($tablename, $entity_type_name, $bundl
       continue;
     }
 
-
     // If this field is a foreign key field then we will have a special custom
     // field provided by Tripal.
     $is_fk = FALSE;

+ 1 - 1
tripal_entities/includes/tripal_entities.field_storage.inc

@@ -77,7 +77,7 @@ function tripal_entities_field_storage_load($entity_type, $entities, $age, $fiel
   global $language;
   $langcode = $language->language;
 
-  foreach ($entities as $entity_id => $entity) {
+  foreach ($entities as $id => $entity) {
     // Find out which table should receive the insert.
     $tablename = 'feature';
     $type_field = 'type_id';

+ 2 - 2
tripal_entities/tripal_entities.install

@@ -314,7 +314,7 @@ function tripal_entities_schema() {
   $schema['tripal_data'] = array(
     'description' => 'The base table for Tripal Vocabulary-based entities.',
     'fields' => array(
-      'entity_id' => array(
+      'id' => array(
         'description' => 'The primary identifier for a vocabulary entity.',
         'type' => 'serial',
         'unsigned' => TRUE,
@@ -390,7 +390,7 @@ function tripal_entities_schema() {
     'unique keys' => array(
       'record' => array('tablename', 'record_id'),
     ),
-    'primary key' => array('entity_id'),
+    'primary key' => array('id'),
   );
 
   $schema['tripal_data_type'] = array(

+ 1 - 1
tripal_entities/tripal_entities.module

@@ -167,7 +167,7 @@ function tripal_entities_entity_info() {
     // functions. It is not required if we don't have bundles or revisions.
     // Here we do not support a revision, so that entity key is omitted.
     'entity keys' => array(
-      'id' => 'entity_id',
+      'id' => 'id',
       'bundle' => 'type',
     ),
     'bundle keys' => array(