Browse Source

Reworked the TripalField class to follow Drupal coding standards (except naming), and to make functions more intuitive

Stephen Ficklin 8 years ago
parent
commit
9d581f4056
30 changed files with 1396 additions and 1142 deletions
  1. 101 73
      tripal/api/tripal.entities.api.inc
  2. 113 0
      tripal/api/tripal.fields.api.inc
  3. 1 10
      tripal/includes/TripalBundleController.inc
  4. 3 2
      tripal/includes/TripalEntityController.inc
  5. 138 61
      tripal/includes/TripalField.inc
  6. 62 56
      tripal/includes/fields/content_type.inc
  7. 51 41
      tripal/includes/tripal.fields.inc
  8. 1 1
      tripal/tripal.module
  9. 48 43
      tripal_chado/includes/fields/chado_base__dbxref_id.inc
  10. 48 41
      tripal_chado/includes/fields/chado_base__organism_id.inc
  11. 45 40
      tripal_chado/includes/fields/chado_feature__md5checksum.inc
  12. 44 39
      tripal_chado/includes/fields/chado_feature__residues.inc
  13. 45 40
      tripal_chado/includes/fields/chado_feature__seqlen.inc
  14. 48 48
      tripal_chado/includes/fields/chado_gene__transcripts.inc
  15. 46 41
      tripal_chado/includes/fields/chado_linker__contact.inc
  16. 28 24
      tripal_chado/includes/fields/chado_linker__cvterm.inc
  17. 39 36
      tripal_chado/includes/fields/chado_linker__cvterm_adder.inc
  18. 49 44
      tripal_chado/includes/fields/chado_linker__dbxref.inc
  19. 43 38
      tripal_chado/includes/fields/chado_linker__expression.inc
  20. 45 40
      tripal_chado/includes/fields/chado_linker__featureloc.inc
  21. 45 40
      tripal_chado/includes/fields/chado_linker__genotype.inc
  22. 45 40
      tripal_chado/includes/fields/chado_linker__phenotype.inc
  23. 27 33
      tripal_chado/includes/fields/chado_linker__prop.inc
  24. 39 36
      tripal_chado/includes/fields/chado_linker__prop_adder.inc
  25. 45 40
      tripal_chado/includes/fields/chado_linker__pub.inc
  26. 45 40
      tripal_chado/includes/fields/chado_linker__relationship.inc
  27. 45 40
      tripal_chado/includes/fields/chado_linker__synonym.inc
  28. 41 36
      tripal_chado/includes/fields/chado_organism__type_id.inc
  29. 12 1
      tripal_chado/includes/tripal_chado.entity.inc
  30. 54 118
      tripal_chado/includes/tripal_chado.fields.inc

+ 101 - 73
tripal/api/tripal.entities.api.inc

@@ -160,6 +160,16 @@ function tripal_load_bundle_entity($values) {
   }
   return NULL;
 }
+
+/**
+ * Allows a module to perform tasks after a TripalBundle object is created.
+ *
+ * @param $bundle
+ *   The newly created TripalBundle object.
+ */
+function hook_bundle_create(&$bundle) {
+
+}
 /**
  * Creates a new Tripal Entity type (i.e. bundle).
  *
@@ -180,92 +190,110 @@ function tripal_load_bundle_entity($values) {
  */
 function tripal_create_bundle($vocabulary, $accession, $term_name, &$error = '') {
 
-  // First create the TripalVocab if it doesn't already exist.
-  $vocab = tripal_load_vocab_entity(array('vocabulary' => $vocabulary));
-  if (!$vocab) {
-    $vocab = entity_get_controller('TripalVocab')->create(array('vocabulary' => $vocabulary));
-    $vocab->save();
-  }
-
-  // Next create the TripalTerm if it doesn't already exist.
-  $term = tripal_load_term_entity(array(
-    'vocabulary' => $vocabulary,
-    'accession' => $accession
-  ));
-  if (!$term) {
-    $args = array('vocab_id' => $vocab->id, 'accession' => $accession, 'name' => $term_name);
-    $term = entity_get_controller('TripalTerm')->create($args);
-    $term = $term->save();
-  }
-
-  // If the bundle doesn't already exist, then add it.
-  $bundle_name = 'bio_data_' . $term->id;
-  $einfo = entity_get_info('TripalEntity');
-  if (!in_array($bundle_name, array_keys($einfo['bundles']))) {
-    // Insert the bundle.
-    db_insert('tripal_bundle')
-      ->fields(array(
-        'label' => $term_name,
-        'type' => 'TripalEntity',
-        'name' => $bundle_name,
-        'term_id' => $term->id,
-      ))
-      ->execute();
-  }
-
-  // Clear the entity cache so that Drupal will read our
-  // hook_entity_info() implementation.
-  global $language;
-  $langcode = $language->language;
-  cache_clear_all("entity_info:$langcode", 'cache');
-  variable_set('menu_rebuild_needed', TRUE);
+  $transaction = db_transaction();
+  try {
+    // First create the TripalVocab if it doesn't already exist.
+    $vocab = tripal_load_vocab_entity(array('vocabulary' => $vocabulary));
+    if (!$vocab) {
+      $vocab = entity_get_controller('TripalVocab')->create(array('vocabulary' => $vocabulary));
+      $vocab->save();
+    }
 
-  // Get the bundle object.
-  $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+    // Next create the TripalTerm if it doesn't already exist.
+    $term = tripal_load_term_entity(array(
+      'vocabulary' => $vocabulary,
+      'accession' => $accession
+    ));
+    if (!$term) {
+      $args = array('vocab_id' => $vocab->id, 'accession' => $accession, 'name' => $term_name);
+      $term = entity_get_controller('TripalTerm')->create($args);
+      $term = $term->save();
+    }
 
-  // Get the list of fields to create.
-  foreach (module_implements('field_create_info') as $module) {
-    $function = $module . '_field_create_info';
-    if (function_exists($function)) {
-      $fields = $function('TripalEntity', $bundle, $term);
-      if (!$fields){
-        continue;
-      }
-      foreach ($fields as $field_name => $info) {
-        // If the field already exists then skip it.
-        $field = field_info_field($info['field_name']);
-        if ($field) {
+    // If the bundle doesn't already exist, then add it.
+    $bundle_name = 'bio_data_' . $term->id;
+    $einfo = entity_get_info('TripalEntity');
+    if (!in_array($bundle_name, array_keys($einfo['bundles']))) {
+      // Insert the bundle.
+      db_insert('tripal_bundle')
+        ->fields(array(
+          'label' => $term_name,
+          'type' => 'TripalEntity',
+          'name' => $bundle_name,
+          'term_id' => $term->id,
+        ))
+        ->execute();
+    }
+
+    // Allow modules to make additions to the entity when it's created.
+    $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+    $modules = module_implements('bundle_create');
+    foreach ($modules as $module) {
+      $function = $module . '_bundle_create';
+      $function($bundle);
+    }
+
+    // Clear the entity cache so that Drupal will read our
+    // hook_entity_info() implementation.
+    global $language;
+    $langcode = $language->language;
+    cache_clear_all("entity_info:$langcode", 'cache');
+    variable_set('menu_rebuild_needed', TRUE);
+
+    // Get the bundle object.
+    $bundle = tripal_load_bundle_entity(array('name' => $bundle_name));
+
+    // Get the list of fields to create.
+    foreach (module_implements('field_create_info') as $module) {
+      $function = $module . '_field_create_info';
+      if (function_exists($function)) {
+        $fields = $function('TripalEntity', $bundle);
+        if (!$fields){
           continue;
         }
-        $field = field_create_field($info);
-        if (!$field) {
-          tripal_set_message(t("Could not create new field: %field.",
-            array('%field' =>  $info['field_name'])), TRIPAL_ERROR);
+        foreach ($fields as $field_name => $info) {
+          // If the field already exists then skip it.
+          $field = field_info_field($info['field_name']);
+          if ($field) {
+            continue;
+          }
+          $field = field_create_field($info);
+          if (!$field) {
+            tripal_set_message(t("Could not create new field: %field.",
+              array('%field' =>  $info['field_name'])), TRIPAL_ERROR);
+          }
         }
       }
     }
-  }
 
-  // Now get the list of field instances to add to the bundle.
-  foreach (module_implements('field_create_instance_info') as $module) {
-    $function = $module . '_field_create_instance_info';
-    if (function_exists($function)) {
-      $fields = $function('TripalEntity', $bundle, $term);
-      if (!$fields){
-        continue;
-      }
-      foreach ($fields as $field_name => $info) {
-        // If the field is already attached to this bundle then skip it.
-        $field = field_info_field($info['field_name']);
-        if ($field and array_key_exists('bundles', $field) and
-            array_key_exists('TripalEntity', $field['bundles']) and
-            in_array($bundle_name, $field['bundles']['TripalEntity'])) {
+    // Now get the list of field instances to add to the bundle.
+    foreach (module_implements('field_create_instance_info') as $module) {
+      $function = $module . '_field_create_instance_info';
+      if (function_exists($function)) {
+        $fields = $function('TripalEntity', $bundle);
+        if (!$fields){
           continue;
         }
-        $instance = field_create_instance($info);
+        foreach ($fields as $field_name => $info) {
+          // If the field is already attached to this bundle then skip it.
+          $field = field_info_field($info['field_name']);
+          if ($field and array_key_exists('bundles', $field) and
+              array_key_exists('TripalEntity', $field['bundles']) and
+              in_array($bundle_name, $field['bundles']['TripalEntity'])) {
+            continue;
+          }
+          $instance = field_create_instance($info);
+        }
       }
     }
   }
+  catch (Exception $e) {
+    $transaction->rollback();
+    $error = _drupal_decode_exception($e);
+    drupal_set_message(t("Failed to create content type': %message",
+        array('%message' => $error['!message'])), 'error');
+    return FALSE;
+  }
 
   return TRUE;
 }

+ 113 - 0
tripal/api/tripal.fields.api.inc

@@ -0,0 +1,113 @@
+<?php
+
+/**
+ * Retrieves a list of TripalField class instances for a given module.
+ *
+ * The TripalField classes can be added by a site developer and should be
+ * placed in the [module]/includes/fields directory.  Tripal will support
+ * any field as long as it is in this directory and extends the TripalField
+ * class.  To support dynamic inclusion of new fields this function
+ * will look for TripalField class files and return a list of instantiated
+ * objects for all of them.
+ *
+ * @param $module
+ *   The module that provides fields.
+ * @param $entity_type
+ *   The type of entity (e.g. TripalEntity).
+ * @param $bundle
+ *   The bundle object.  This is the bundle that is being offered
+ *   to the field for attachement. The function will determine if this
+ *   field should be attached to this bundle.
+ * @param $details
+ *   An array of additional "details" that are required by the modue that
+ *   implements this field. For example, an associative array of values
+ *   needed for the field to work properly.
+ * @return
+ *   A list of TripalField objects.  If no field can be found in the
+ *   module then an empty array is returned.
+ */
+function tripal_get_fields($module, $entity_type, $bundle, $details = array()) {
+
+  $objects = array();
+
+  // Find all of the files in the tripal_chado/includes/fields directory.
+  $fields_path = drupal_get_path('module', $module) . '/includes/fields';
+  $field_files = file_scan_directory($fields_path, '/.*\.inc$/');
+
+  // Iterate through the fields, include the file and run the info function.
+  foreach ($field_files as $file) {
+    $field_type = $file->name;
+    module_load_include('inc', $module, 'includes/fields/' . $field_type);
+    if (class_exists($field_type)) {
+      $objects[] = new $field_type($entity_type, $bundle, $details);
+    }
+  }
+
+  return $objects;
+}
+/**
+ * Retrieves a list of TripalField types.
+ *
+ * The TripalField classes can be added by a site developer and should be
+ * placed in the [module]/includes/fields directory.  Tripal will support
+ * any field as long as it is in this directory and extends the TripalField
+ * class.  To support dynamic inclusion of new fields this function
+ * will look for TripalField class files and return a type for
+ * each one.
+ *
+ * @param $module
+ *   The module that provides fields.
+ * @return
+ *   A list of TripalField field type.
+ */
+function tripal_get_field_types($module) {
+  $types = array();
+
+  // Find all of the files in the tripal_chado/includes/fields directory.
+  $fields_path = drupal_get_path('module', $module) . '/includes/fields';
+  $field_files = file_scan_directory($fields_path, '/.*\.inc$/');
+
+  // Iterate through the fields, include the file and run the info function.
+  foreach ($field_files as $file) {
+    $field_type = $file->name;
+    module_load_include('inc', $module, 'includes/fields/' . $field_type);
+    if (class_exists($field_type)) {
+      $types[] = $field_type;
+    }
+  }
+
+  return $types;
+}
+/**
+ * Retreives an intance of a TripalField class.
+ *
+ * The TripalField classes can be added by a site developer and should be
+ * placed in the [module]/includes/fields directory.  Tripal will support
+ * any field as long as it is in this directory and extends the TripalField
+ * class.  To support dynamic inclusion of new fields this function
+ * serves as a wrapper for locating the appropriate class file and
+ * instantiating the object.
+ *
+ * @param $field_type
+ *   The type of field to instantiate
+ * @param $module
+ *   The module that provides this field.
+ * @param $entity_type
+ *   The type of entity (e.g. TripalEntity).
+ * @param $bundle
+ *   The bundle object.  This is the bundle that is being offered
+ *   to the field for attachement. The function will determine if this
+ *   field should be attached to this bundle.
+ * @param $details
+ *   An array of additional "details" that are required by the modue that
+ *   implements this field. For example, an associative array of values
+ *   needed for the field to work properly.
+ */
+function tripal_get_field($field_type, $module, $entity_type, $bundle, $details = array()) {
+
+  module_load_include('inc', $module, 'includes/fields/' . $field_type);
+  if (class_exists($field_type)) {
+    return new $field_type($entity_type, $bundle, $details);
+  }
+  return NULL;
+}

+ 1 - 10
tripal/includes/TripalBundleController.inc

@@ -26,16 +26,7 @@ class TripalBundleController extends EntityAPIControllerExportable {
       'is_new' => TRUE,
       'data' => '',
     );
-    $bundle = parent::create($values);
-
-    // Allow modules to make additions to the entity when it's created.
-    $modules = module_implements('bundle_create');
-    foreach ($modules as $module) {
-      $function = $module . '_bundle_create';
-      $function($bundle);
-    }
-
-    return $bundle;
+    return parent::create($values);
   }
 
   /**

+ 3 - 2
tripal/includes/TripalEntityController.inc

@@ -187,11 +187,12 @@ class TripalEntityController extends EntityAPIController {
         // SQL statement that gets called somewhere by Drupal:
         // SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM url_alias.
         // Perhaps we should write our own SQL to avoid this issue.
-        drupal_write_record('url_alias', array(
+        $values =  array(
           'source' => $source_url,
           'alias' => $alias,
           'language' => 'und',
-        ));
+        );
+        drupal_write_record('url_alias', $values);
 //        path_delete(array('source' => $source_url));
 //        $path = array('source' => $source_url, 'alias' => $alias);
 //        path_save($path);

+ 138 - 61
tripal/includes/TripalField.inc

@@ -37,13 +37,121 @@
  *
  */
 class TripalField {
+
+  // The type of Entity (e.g. TripalEntity).
+  protected $entity_type = '';
+  // The bundle to which this field may be attached.
+  protected $bundle = NULL;
+  // The name of this field.
+  protected $field_name = '';
+  // The type of field.
+  protected $field_type = '';
+  // Set to TRUE if this field is attached to the bundle.  TripalFields are
+  // allowed to decide if they want to be attached to bundles or not.
+  protected $can_attach = FALSE;
+  // An array of paramters that can be used by the field. This is typically
+  // passed by the module that provides the field.
+  protected $details = array();
+
+  /**
+   * The TripalField constructor.
+   */
+  public function __construct($entity_type, $bundle, $details = array()) {
+    $this->entity_type = $entity_type;
+    $this->bundle = $bundle;
+    $this->details = $details;
+
+    // Set the field type. This will always be the name of the file. The
+    // field type, class name and file name must all be identical or things
+    // will break.
+    $this->field_type = get_class($this);
+
+    // Determine if this field can attach to the bundle.
+    $this->setCanAttach($bundle, $details);
+
+    // Set the field's name.
+    $this->setFieldName($bundle, $details);
+  }
+
+  /**
+   * Allows the child class to set the field name.
+   */
+  protected function setFieldName() {
+    // Set the field name to default to be the same as the field type. Any
+    // classes that extend this one can adjust the field name as needed.
+    $this->field_name = $this->field_type;
+  }
+
+  /**
+   * Retrives the name of this field.
+   *
+   * @return
+   *   This field's name.
+   */
+  public function getFieldName() {
+    return $this->field_name;
+  }
+
+  /**
+   * A helper function to determine if this field wants to attach to a bundle.
+   *
+   * Any class that extends the TripalField class can override this function but
+   * it should set the $this->can_attach member to TRUE or FALSE.
+   *
+   * @param $entity_type
+   *   The entity type Class to which the bundle belongs.
+   * @param $bundle.
+   *   An instance of a TripalBundle object.  This is the bundle to which
+   *   the field can be added.
+   * @param $details
+   *   An associative array containing additional details provided by the
+   *   calling module that can be used by the function to determine if the
+   *   bundle should be attached to.
+   */
+  protected function setCanAttach() {
+    $this->can_attach = FALSE;
+  }
+
   /**
-   * Define this field type.
+   * Retrieves the type of field for this field.
    *
    * @return
-   * An array whose keys are field type names and whose values are arrays
-   * describing the field type. The keys are the same as for the
-   * hook_field_info() function, which are:
+   *   The field's type.
+   */
+  public function getType() {
+    return $this->field_type;
+  }
+
+  /**
+   * Retrieves the bundle that this field was provided.
+   *
+   * @return
+   *   A bundle object.
+   */
+  public function getBundle() {
+    return $this->bundle;
+  }
+  /**
+   * Indicates if the field should be attached to the bundle.
+   *
+   * @return
+   *   TRUE if the field wants to be attached to the bundle that was provdied
+   *   in the constructor. FALSE otherwise.
+   */
+  public function canAttach() {
+    return $this->can_attach;
+  }
+
+  /**
+   * Provides default settings for the field.
+   *
+   * This is a static function and defines defaults for all fields of this
+   * type.
+   *
+   * @return
+   *   An array whose keys are field type names and whose values are arrays
+   *   describing the field type. The keys are the same as for the
+   *   hook_field_info() function, which are:
    *   - label: The human-readable name of the field type.
    *   - description: A short description for the field type.
    *   - settings: An array whose keys are the names of the settings available
@@ -76,7 +184,7 @@ class TripalField {
    *     field_create_field() and field_create_instance(). Defaults to
    *     FALSE.
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
     );
   }
@@ -92,13 +200,6 @@ class TripalField {
    * passed as arguments to allow the field to decide if it wants to be
    * attached.
    *
-   * @param $entity_type
-   *   The class name for the entity type (e.g. TripalEntity).
-   * @param TripalBundle $bundle
-   *   The TripalBundle object.  This is the bundle that is being offered
-   *   to the field for attachement. The function will determine if this
-   *   field should be attached to this bundle.
-   * @param $details
    * @return
    *   A field definition array. The return value is identical to that
    *   provided to the field_create_info() function. The field_name and
@@ -120,8 +221,8 @@ class TripalField {
    *
    *  Nothing is returned when this field will not be attached to the bundle.
    */
-  public function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  public function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
   }
@@ -184,50 +285,22 @@ class TripalField {
    *
    *  Nothing is returned when this field will not be attached to the bundle.
    */
-  public function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  public function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
   }
 
-
-
   /**
-   * A helper function to determine if this field wants to attach to a bundle.
+   * Provides information about the widgets provided by this field.
    *
-   * Because the create_info() and create_instance_info() functions both need
-   * to determine if they should attach to a bundle, this function is provided
-   * as a helper function to perform that check.  Any class that extends the
-   * TripalField class can use this function provide a single function that
-   * both create_info() and create_instance_info() can use.
+   * This function returns an array describing the widget types implemented by
+   * the field.  The widgets created by this field are expecte to be used only
+   * by this field.
    *
-   * @param $entity_type
-   *   The entity type Class to which the bundle belongs.
-   * @param $bundle.
-   *   An instance of a TripalBundle object.  This is the bundle to which
-   *   the field can be added.
-   * @param $details
-   *   An associative array containing additional details provided by the
-   *   calling module that can be used by the function to determine if the
-   *   bundle should be attached to.
-   *
-   * @return
-   *   TRUE if the field should attach to the bundle. FALSE if not.
-   */
-  protected function can_attach($entity_type, $bundle, $details) {
-
-  }
-
-  public function attach_info($entity_type, $bundle, $settings) {
-
-  }
-
-  /**
-   *  Provides information about the widgets provided by this field.
-   *
-   *  This function returns an array describing the widget types implemented by
-   *  the field.  The widgets created by this field are expecte to be used only
-   *  by this field.
+   * This is a static function as it provides default values for all of the
+   * widgets for this field type, and thus we don't need an instantiated
+   * object to provide this information.
    *
    * @param $entity_type
    *   The entity type Class to which the bundle belongs.
@@ -269,19 +342,23 @@ class TripalField {
    *       widget relative to other widgets in the Field UI when selecting a
    *       widget for a given field instance.
    */
-  public function widget_info() {
+  public static function widgetInfo() {
     return array(
     );
   }
   /**
    * Provides information about the formatter for this field.
    *
+   * This is a static function as it provides default values for all of the
+   * formatters for this field type, and thus we don't need an instantiated
+   * object to provide this information.
+   *
    * @return
    *   An associative array with key/value paris compatible with those from the
    *   hook_field_formatter_info() function of the Drupal Field API.
    *
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
     );
   }
@@ -309,7 +386,7 @@ class TripalField {
    *   to the user.
    *
    */
-  public function formatter_settings_summary($field, $instance, $view_mode) {
+  public function formatterSettingsSummary($field, $instance, $view_mode) {
 
   }
 
@@ -336,7 +413,7 @@ class TripalField {
    * @return
    *   A Drupal Form array containing the settings form for this field.
    */
-  public function formatter_settings_form($field, $instance,
+  public function formatterSettingsForm($field, $instance,
       $view_mode, $form, &$form_state) {
 
   }
@@ -364,7 +441,7 @@ class TripalField {
    *    An element array compatible with that returned by the
    *    hook_field_formatter_view() function.
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     foreach($items as $delta => $item) {
@@ -406,7 +483,7 @@ class TripalField {
    * @return
    *   A Drupal form. See the hook_field_widget_form() function for more information.
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $widget['value'] = array(
@@ -443,7 +520,7 @@ class TripalField {
    *      - message: The human readable message to be displayed.
    *
    */
-  public function validate($entity_type, $entity, $field, $instance, $langcode,
+  public static function widgetFormValidate($entity_type, $entity, $field, $instance, $langcode,
       $items, &$errors) {
 
   }
@@ -476,7 +553,7 @@ class TripalField {
    *  @param $form_state.
    *    The form state array.
    */
-  public function submit($entity_type, $entity, $field, $instance, $langcode,
+  public static function widgetFormSubmit($entity_type, $entity, $field, $instance, $langcode,
       &$items, $form, &$form_state) {
   }
   /**
@@ -525,7 +602,7 @@ class TripalField {
    * @param $has_data
    *   TRUE if the field already has data, FALSE if not.
    */
-  public function settings_form($field, $instance, $has_data) {
+  public function settingsForm($field, $instance, $has_data) {
     $settings = $field['settings'];
     $element = array();
 
@@ -556,7 +633,7 @@ class TripalField {
    * @return
    *   An associative array describing the data structure of the field.
    */
-  public function views_data_alter(&$data, $field, $entity_info) {
+  public static function viewsDataAlter(&$data, $field, $entity_info) {
 
   }
 

+ 62 - 56
tripal/includes/fields/content_type.inc

@@ -1,10 +1,27 @@
 <?php
 
 class content_type extends TripalField {
+
+  /**
+   * @see TripalField::setFieldName()
+   */
+  protected function setFieldName() {
+    $this->field_name = 'content_type';
+  }
+
+  /**
+   * @see TripalField::setCanAttach()
+   */
+  protected function setCanAttach() {
+    // We always attach to TriplEntity entities.
+    if ($this->entity_type == 'TripalEntity') {
+      $this->can_attach = TRUE;
+    }
+  }
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Record Type'),
       'description' => t('The content type.'),
@@ -19,48 +36,15 @@ class content_type extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
-   */
-  function widget_info() {
-    return array(
-      'tripal_content_type_widget' => array(
-        'label' => t('Record Type'),
-        'field types' => array('content_type')
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatter_info()
-   */
-  function formatter_info() {
-    return array(
-      'tripal_content_type_formatter' => array(
-        'label' => t('Record Type'),
-        'field types' => array('content_type')
-      ),
-    );
-  }
-  /**
-   * @see TripalField::can_attach()
+   * @see TripalField::createFieldInfo()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    // We always attach to TriplEntity entities.
-    if ($entity_type == 'TripalEntity') {
-      return TRUE;
-    }
-  }
-
-  /**
-   * @see TripalField::create_info()
-   */
-  public function create_info($entity_type, $bundle, $details) {
-
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  public function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
     return array(
-      'field_name' => 'content_type',
+      'field_name' => $this->field_name,
       'type' => 'content_type',
       'cardinality' => 1,
       'locked' => FALSE,
@@ -73,18 +57,18 @@ class content_type extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  public function create_instance_info($entity_type, $bundle, $details) {
+  public function createInstanceInfo() {
 
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+    if (!$this->can_attach) {
       return;
     }
 
     return array(
-      'field_name' => 'content_type',
+      'field_name' => $this->field_name,
       'entity_type' => 'TripalEntity',
-      'bundle' => $bundle->name,
+      'bundle' => $this->bundle->name,
       'label' => 'Resource Type',
       'description' => '',
       'required' => FALSE,
@@ -104,11 +88,41 @@ class content_type extends TripalField {
       ),
     );
   }
+  /**
+   * @see TripalField::widgetInfo()
+   */
+  static function widgetInfo() {
+    return array(
+      'tripal_content_type_widget' => array(
+        'label' => t('Record Type'),
+        'field types' => array('content_type')
+      ),
+    );
+  }
+  /**
+   * @see TripalField::formatterInfo()
+   */
+  static function formatterInfo() {
+    return array(
+      'tripal_content_type_formatter' => array(
+        'label' => t('Record Type'),
+        'field types' => array('content_type')
+      ),
+    );
+  }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::load()
    */
-  function formatter_view(&$element, $entity_type, $entity,
+  function load($field, $entity, $details) {
+
+    $entity->{$this->field_name}['und'][0]['value'] = $this->bundle->label;
+  }
+
+  /**
+   * @see TripalField::formatterView()
+   */
+  static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
@@ -119,9 +133,9 @@ class content_type extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $widget = $element;
@@ -132,13 +146,5 @@ class content_type extends TripalField {
     }
 
   }
-  /**
-   * @see TripalField::load()
-   */
-  function load($field, $entity) {
 
-    $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
-    $field_name = $field['field_name'];
-    $entity->{$field_name}['und'][0]['value'] = $bundle->label;
-  }
 }

+ 51 - 41
tripal/includes/tripal.fields.inc

@@ -6,24 +6,31 @@
 function tripal_field_info() {
 
   $info = array();
-  $fields = tripal_get_fields('tripal');
-  foreach ($fields as $field) {
-    $info[] = $field->field_info();
-  }
-
-}
-/**
- * Implements hook_field_widget_info();
- */
-function tripal_field_widget_info() {
 
+  $field_types = tripal_get_field_types('tripal');
+  foreach ($field_types as $field_type) {
+    $info[$field_type] = $field_type::fieldInfo();
+  }
+  return $info;
 }
 
 /**
- * Implements hook_field_formatter_info().
+ * Implements hook_field_create_info().
+ *
+ * This is a Tripal defined hook that supports integration with the
+ * TripalEntity field.
  */
-function tripal_field_formatter_info() {
+function tripal_field_create_info($entity_type, $bundle) {
 
+  $info = array();
+  $fields = tripal_get_fields('tripal', $entity_type, $bundle);
+  foreach ($fields as $field) {
+    $field_name = $field->getFieldName();
+    if ($field->canAttach()) {
+      $info[$field_name] = $field->createInfo();
+    }
+  }
+  return $info;
 }
 
 /**
@@ -32,45 +39,43 @@ function tripal_field_formatter_info() {
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_field_create_instance_info($entity_type, $bundle, $term) {
-
+function tripal_field_create_instance_info($entity_type, $bundle) {
+  $info = array();
+  $fields = tripal_get_fields('tripal', $entity_type, $bundle);
+  foreach ($fields as $field) {
+    $field_name = $field->getFieldName();
+    if ($field->canAttach()) {
+      $info[$field_name] = $field->createInstanceInfo();
+    }
+  }
+  return $info;
 }
-
 /**
- * Implements hook_field_widget_form().
+ * Implements hook_field_widget_info();
  */
-function tripal_field_widget_form(&$form, &$form_state, $field,
-    $instance, $langcode, $items, $delta, $element) {
-
+function tripal_field_widget_info() {
+  $info = array();
 
+  $field_types = tripal_get_field_types('tripal');
+  foreach ($field_types as $field_type) {
+    $info += $field_type::widgetInfo();
+  }
+  return $info;
 }
+
 /**
- * Implements hook_field_create_info().
- *
- * This is a Tripal defined hook that supports integration with the
- * TripalEntity field.
+ * Implements hook_field_formatter_info().
  */
-function tripal_field_create_info($entity_type, $bundle, $term) {
+function tripal_field_formatter_info() {
   $info = array();
 
-  // Find all of the files in the tripal_chado/includes/fields directory.
-  $fields_path = drupal_get_path('module', 'tripal') . '/includes/fields';
-  $field_files = file_scan_directory($fields_path, '/^.inc$/');
-
-  // Iterate through the fields, include the file and run the info function.
-  foreach ($field_files as $file) {
-    $field_type = $file->name;
-    module_load_include('inc', 'tripal', 'includes/fields/' . $field_type);
-    if (class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $result = $field_obj->create_info($entity_type, $bundle, $details);
-      if (is_array($result)) {
-        $info[$result['field_name']] = $result;
-      }
-    }
+  $field_types = tripal_get_field_types('tripal');
+  foreach ($field_types as $field_type) {
+    $info += $field_type::formatterInfo();
   }
   return $info;
 }
+
 /**
  * Implements hook_field_formatter_view().
  */
@@ -81,9 +86,10 @@ function tripal_field_formatter_view($entity_type, $entity, $field,
   $field_type = $field['type'];
   module_load_include('inc', 'tripal', 'includes/fields/' . $field_type);
   if (class_exists($field_type)) {
-    $field_obj = new $field_type();
-    $field_obj->formatter_view($element, $entity_type, $entity, $field, $instance, $langcode, $items, $display);
+    $field_obj = new $field_type($entity_type, $entity->bundle);
+    $field_obj::formatterView($element, $entity_type, $entity, $field, $instance, $langcode, $items, $display);
   }
+  return $element;
 }
 /**
  * Implements hook_field_is_empty().
@@ -109,6 +115,10 @@ function tripal_field_is_empty($item, $field) {
 
 /**
  * Simple provides a message indicating that the field cannot be deleted.
+ *
+ * This function is used in the tripal_menu_alter() function.  We alter the
+ * menu created for managing fields to use this call back which
+ * prints a message that the field cannot be deleted.
  */
 function tripal_field_no_delete() {
   drupal_set_message('This field cannot be removed.', 'warning');

+ 1 - 1
tripal/tripal.module

@@ -108,7 +108,7 @@ function tripal_menu() {
   );
 
   $items['admin/tripal/storage'] = array(
-    'title' => 'Storage Backend',
+    'title' => 'Data Storage Settings',
     'description' => t("Tripal is designed to access biological
         data in any data storage back-end.  A storage back-end must have a
         module that can be installed that interfaces with Tripal.  By default

+ 48 - 43
tripal_chado/includes/fields/chado_base__dbxref_id.inc

@@ -2,9 +2,9 @@
 
 class chado_base__dbxref_id extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Accession'),
       'description' => t('This field specifies the unique stable accession (ID) for
@@ -22,39 +22,41 @@ class chado_base__dbxref_id extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
+  protected function setCanAttach() {
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // Check the schema for the data table if it does not have
     // a 'dbxref_id' column then we don't want to attach this field.
     $schema = chado_get_schema($table_name);
     if (!$schema) {
-      return FALSE;
+      $this->can_attach = FALSE;
+      return;
     }
     if (array_key_exists('dbxref_id', $schema['fields'])) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
 
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     };
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__dbxref_id',
@@ -73,22 +75,22 @@ class chado_base__dbxref_id extends TripalField {
   }
 
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__dbxref_id',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Accession',
       'description' => 'This field specifies the unique stable accession (ID) for
         this record. It requires that this site have a database entry.',
@@ -112,31 +114,34 @@ class chado_base__dbxref_id extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Accession'),
-      'field types' => array('chado_base__dbxref_id'),
-      'description' => t('This field specifies the unique stable accession (ID) for
-        this record. It requires that this site have a database entry.'),
+      'chado_base__dbxref_id_widget' => array(
+        'label' => t('Accession'),
+        'field types' => array('chado_base__dbxref_id'),
+        'description' => t('This field specifies the unique stable accession (ID) for
+          this record. It requires that this site have a database entry.'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Accession'),
-      'field types' => array('chado_base__dbxref_id'),
-      'settings' => array(
+      'chado_base__dbxref_id_formatter' => array(
+        'label' => t('Accession'),
+        'field types' => array('chado_base__dbxref_id'),
+        'settings' => array(),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
@@ -153,9 +158,9 @@ class chado_base__dbxref_id extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $field_name = $field['field_name'];

+ 48 - 41
tripal_chado/includes/fields/chado_base__organism_id.inc

@@ -5,7 +5,7 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::info()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Organism'),
       'description' => t('A field for specifying an organism.'),
@@ -24,48 +24,51 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
+  protected function setCanAttach() {
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $schema = chado_get_schema($table_name);
     if (!$schema) {
-      return FALSE;
+      $this->can_attach = FALSE;
+      return;
     }
 
     // If this is the organism table then do not attach as the organism_id
     // field is the primary key and we don't want a field for that.
     if ($table_name == 'organism') {
-      return FALSE;
+      $this->can_attach = FALSE;
+      return;
     }
 
     // Check the schema for the data table if it has
     // an 'organism_id' column then we want to attach this field.
     if (array_key_exists('organism_id', $schema['fields'])) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
 
-    return FALSE;
+    $this->can_attach = FALSE;
   }
 
   /**
    * @see TripalField::create_info()
    */
-  public function create_info($entity_type, $bundle, $details) {
+  public function createInfo() {
 
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__organism_id',
@@ -83,19 +86,19 @@ class chado_base__organism_id extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  public function create_instance_info($entity_type, $bundle, $details) {
+  public function createInstanceInfo() {
 
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $is_required = FALSE;
     $schema = chado_get_schema($table_name);
@@ -106,8 +109,8 @@ class chado_base__organism_id extends TripalField {
 
     return array(
       'field_name' => $table_name . '__organism_id',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Organism',
       'description' => 'Select an organism.',
       'required' => $is_required,
@@ -131,30 +134,34 @@ class chado_base__organism_id extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  public function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Organism Select'),
-      'field types' => array('chado_base__organism_id')
+      'chado_base__organism_id_widget' => array(
+        'label' => t('Organism Select'),
+        'field types' => array('chado_base__organism_id')
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Organism'),
-      'field types' => array('chado_base__organism_id'),
-      'settings' => array(
+      'chado_base__organism_id_formatter' => array(
+        'label' => t('Organism'),
+        'field types' => array('chado_base__organism_id'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     if (count($items) > 0) {
@@ -175,7 +182,7 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::widget()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $settings = $field['settings'];
@@ -244,7 +251,7 @@ class chado_base__organism_id extends TripalField {
   /**
    * @see TripalField::settings_form()
    */
-  public function settings_form($field, $instance, $has_data) {
+  public function settingsForm($field, $instance, $has_data) {
 
     $settings = $field['settings'];
 

+ 45 - 40
tripal_chado/includes/fields/chado_feature__md5checksum.inc

@@ -3,9 +3,9 @@
 class chado_feature__md5checksum  extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Sequence MD5 checksum'),
       'description' => t('A field for generating MD5 checksum for a sequence.'),
@@ -22,31 +22,32 @@ class chado_feature__md5checksum  extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     if ($table_name == 'feature') {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__md5checksum',
@@ -64,23 +65,23 @@ class chado_feature__md5checksum  extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__md5checksum',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Sequence Checksum',
       'description' => 'The MD5 checksum for the sequence. The checksum here
         will always be unique for the raw unformatted sequence. To verify that the
@@ -109,31 +110,35 @@ class chado_feature__md5checksum  extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('MD5 Checksum'),
-      'field types' => array('chado_feature__md5checksum'),
+      'chado_feature__md5checksum_widget' => array(
+        'label' => t('MD5 Checksum'),
+        'field types' => array('chado_feature__md5checksum'),
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('MD5 Checksum'),
-      'field types' => array('chado_feature__md5checksum'),
-      'settings' => array(
+        'chado_feature__md5checksum_formatter' => array(
+        'label' => t('MD5 Checksum'),
+        'field types' => array('chado_feature__md5checksum'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
     foreach ($items as $delta => $item) {
       $content = key_exists('value', $item) ? $item['value'] : '';
@@ -146,9 +151,9 @@ class chado_feature__md5checksum  extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $settings = $field['settings'];

+ 44 - 39
tripal_chado/includes/fields/chado_feature__residues.inc

@@ -3,9 +3,9 @@
 class chado_feature__residues extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Sequences'),
       'description' => t('A field for managing nucleotide and protein residues.'),
@@ -23,32 +23,33 @@ class chado_feature__residues extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If  this is not the feature table then we don't want to attach.
     if ($table_name == 'feature') {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'feature__residues',
@@ -66,22 +67,22 @@ class chado_feature__residues extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'feature__residues',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Sequences',
       'description' => 'All available sequences for this record.',
       'required' => FALSE,
@@ -105,27 +106,31 @@ class chado_feature__residues extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Sequence'),
-      'field types' => array('chado_feature__residues'),
+      'chado_feature__residues_widget' => array(
+        'label' => t('Sequence'),
+        'field types' => array('chado_feature__residues'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Sequences'),
-      'field types' => array('chado_feature__residues'),
+      'chado_feature__residues_formatter' => array(
+        'label' => t('Sequences'),
+        'field types' => array('chado_feature__residues'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
     $num_bases = 50;
@@ -156,9 +161,9 @@ class chado_feature__residues extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
     $settings = $field['settings'];
     $field_name = $field['field_name'];

+ 45 - 40
tripal_chado/includes/fields/chado_feature__seqlen.inc

@@ -2,9 +2,9 @@
 
 class chado_feature__seqlen extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Sequence length'),
       'description' => t('A field for calculating the length of a sequence.'),
@@ -22,30 +22,31 @@ class chado_feature__seqlen extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     if ($table_name == 'feature') {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'feature__seqlen',
@@ -63,22 +64,22 @@ class chado_feature__seqlen extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'feature__seqlen',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Raw Sequence Length',
       'description' => 'The number of residues in the raw sequence.  This length
         is only for the assigned raw sequence and does not represent the length of any
@@ -105,30 +106,34 @@ class chado_feature__seqlen extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Sequence Length'),
-      'field types' => array('chado_feature__seqlen'),
+      'chado_feature__seqlen_widget' => array(
+        'label' => t('Sequence Length'),
+        'field types' => array('chado_feature__seqlen'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Residues Length'),
-      'field types' => array('chado_feature__seqlen'),
-      'settings' => array(
+      'chado_feature__seqlen_formatter' => array(
+        'label' => t('Residues Length'),
+        'field types' => array('chado_feature__seqlen'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     foreach ($items as $delta => $item) {
@@ -140,9 +145,9 @@ class chado_feature__seqlen extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $settings = $field['settings'];

+ 48 - 48
tripal_chado/includes/fields/chado_gene__transcripts.inc

@@ -3,9 +3,9 @@
 class chado_gene__transcripts extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Transcripts'),
       'description' => t('Transcripts of genes.'),
@@ -22,32 +22,33 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists or this is not a gene then we don't want to add attach.
     $rel_table = $table_name . '_relationship';
-    if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
-      return TRUE;
+    if (chado_table_exists($rel_table) and $this->bundle->label == 'gene') {
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $rel_table = $table_name . '_relationship';
     $schema = chado_get_schema($rel_table);
@@ -70,23 +71,23 @@ class chado_gene__transcripts extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'gene_transcripts',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Transcripts',
       'description' => 'These transcripts are associated with this gene.',
       'required' => FALSE,
@@ -110,23 +111,27 @@ class chado_gene__transcripts extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  public function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Transcripts Settings'),
-      'field types' => array('chado_gene__transcripts')
+      'chado_gene__transcripts_widget' => array(
+        'label' => t('Transcripts Settings'),
+        'field types' => array('chado_gene__transcripts')
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Transcripts'),
-      'field types' => array('chado_gene__transcripts'),
-      'settings' => array(
+      'chado_gene__transcripts_formatter' => array(
+        'label' => t('Transcripts'),
+        'field types' => array('chado_gene__transcripts'),
+        'settings' => array(
+        ),
       ),
     );
   }
@@ -134,7 +139,7 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::formatter_settings_summary()
    */
-  public function formatter_settings_summary($field, $instance,
+  public function formatterSettingsSummary($field, $instance,
       $view_mode) {
 
   }
@@ -142,15 +147,15 @@ class chado_gene__transcripts extends TripalField {
   /**
    * @see TripalField::formatter_settings_form()
    */
-  public function formatter_settings_form($field, $instance,
+  public function formatterSettingsForm($field, $instance,
       $view_mode, $form, &$form_state) {
 
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     // Get the settings
@@ -261,14 +266,9 @@ class chado_gene__transcripts extends TripalField {
     }
   }
   /**
-   * @see TripalField::settings_form()
-   */
-  public function settings_form($field, $instance, $view_mode) {
-  }
-  /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
   }

+ 46 - 41
tripal_chado/includes/fields/chado_linker__contact.inc

@@ -3,9 +3,9 @@
 class chado_linker__contact extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Contacts'),
       'description' => t('Associates an indviddual or organization with
@@ -23,33 +23,35 @@ class chado_linker__contact extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];;
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];;
 
     // If the linker table does not exists then we don't want to add attach.
     $contact_table = $table_name . '_contact';
     if (chado_table_exists($contact_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
+
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $contact_table = $table_name . '_contact';
     $schema = chado_get_schema($contact_table);
@@ -72,24 +74,24 @@ class chado_linker__contact extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];;
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];;
 
     $contact_table = $table_name . '_contact';
 
     return array(
       'field_name' => $contact_table,
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Contacts',
       'description' => 'An individual, organization or entity that has had
         some responsibility for the creation, delivery or maintenance of
@@ -114,32 +116,36 @@ class chado_linker__contact extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Contacts'),
-      'field types' => array('chado_linker__contact'),
+      'chado_linker__contact_widget' => array(
+        'label' => t('Contacts'),
+        'field types' => array('chado_linker__contact'),
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Contacts'),
-      'field types' => array('chado_linker__contact'),
-      'settings' => array(
+      'chado_linker__contact_formatter' => array(
+        'label' => t('Contacts'),
+        'field types' => array('chado_linker__contact'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
@@ -192,12 +198,11 @@ class chado_linker__contact extends TripalField {
 
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
-
   }
 
   /**

+ 28 - 24
tripal_chado/includes/fields/chado_linker__cvterm.inc

@@ -2,9 +2,9 @@
 
 class chado_linker__cvterm extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Annotations'),
       'description' => t('This record can be annotated with terms
@@ -22,56 +22,60 @@ class chado_linker__cvterm extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
+  protected function setCanAttach() {
 
     // This field is only attached by the chado_linker__cvterm_addr field.
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
     // This field is only attached by the chado_linker__cvterm_addr field.
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
     // This field is only attached by the chado_linker__cvterm_addr field.
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Annotations'),
-      'field types' => array('chado_linker__cvterm'),
-      'description' => t('This record can be annotated with terms
-            from other vocabularies.'),
+      'chado_linker__cvterm_widget' => array(
+        'label' => t('Annotations'),
+        'field types' => array('chado_linker__cvterm'),
+        'description' => t('This record can be annotated with terms
+              from other vocabularies.'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Annotations'),
-      'field types' => array('chado_linker__cvterm'),
-      'settings' => array(
+      'chado_linker__cvterm_formatter' => array(
+        'label' => t('Annotations'),
+        'field types' => array('chado_linker__cvterm'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     $headers = array('Term', 'Definition', 'Is Not', 'Reference');
@@ -130,9 +134,9 @@ class chado_linker__cvterm extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];

+ 39 - 36
tripal_chado/includes/fields/chado_linker__cvterm_adder.inc

@@ -1,9 +1,9 @@
 <?php
 class chado_linker__cvterm_addr extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Add an Annotation Type'),
       'description' => t('This record may have any number of types of
@@ -22,36 +22,37 @@ class chado_linker__cvterm_addr extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
+  protected function setCanAttach() {
     $field_info = array();
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
 
     // If the linker table does not exists then we don't want to add attach.
     $cvterm_table = $table_name . '_cvterm';
     if (chado_table_exists($cvterm_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '_cvterm',
@@ -66,22 +67,22 @@ class chado_linker__cvterm_addr extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '_cvterm',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Add Annotation Types',
       'description' => 'Add additional annotations types to this record.',
       'required' => FALSE,
@@ -105,18 +106,20 @@ class chado_linker__cvterm_addr extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Add an Annotation'),
-      'field types' => array('chado_linker__cvterm_adder'),
+      'chado_linker__cvterm_adder_widget' => array(
+        'label' => t('Add an Annotation'),
+        'field types' => array('chado_linker__cvterm_adder'),
+      ),
     );
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     // This field has no value field.  Just a fieldset for adding new annotation types.
@@ -222,10 +225,10 @@ function chado_linker__cvterm_adder_widget_validate($element, &$form_state) {
     if (!$field or !array_key_exists('bundles', $field) or
         !array_key_exists('TripalEntity', $field['bundles']) or
         !in_array($bundle_name, $field['bundles']['TripalEntity'])) {
-      $create_instance_info = array(
+      $createInstanceInfo = array(
         'field_name' => 'cvtmerm',
         'entity_type' => 'TripalEntity',
-        'bundle' => $bundle->name,
+        'bundle' => $this->bundle->name,
         'label' => ucfirst(preg_replace('/_/', ' ', $cv->name)),
         'description' => "Annotations from the $cv->name vocabulary",
         'required' => FALSE,
@@ -244,7 +247,7 @@ function chado_linker__cvterm_adder_widget_validate($element, &$form_state) {
           ),
         ),
       );
-      $instance = field_create_instance($create_instance_info);
+      $instance = field_create_instance($createInstanceInfo);
     }
   }
 }

+ 49 - 44
tripal_chado/includes/fields/chado_linker__dbxref.inc

@@ -14,9 +14,9 @@ class chado_linker__dbxref extends TripalField {
    * Implements hook_info() for fields.
    *
    * This is a hook provided by the tripal_chado module for offloading the
-   * hook_field_info() hook for each field to specify.
+   * hook_fieldInfo() hook for each field to specify.
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Cross references'),
       'description' => t('This record can be cross referenced with a record in
@@ -35,32 +35,33 @@ class chado_linker__dbxref extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $dbxref_table = $table_name . '_dbxref';
     if (chado_table_exists($dbxref_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $dbxref_table = $table_name . '_dbxref';
     $schema = chado_get_schema($dbxref_table);
@@ -83,24 +84,24 @@ class chado_linker__dbxref extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $dbxref_table = $table_name . '_dbxref';
     return array(
       'field_name' => $dbxref_table,
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Cross References',
       'description' => 'The IDs where this record may be available in other external online databases.',
       'required' => FALSE,
@@ -124,33 +125,37 @@ class chado_linker__dbxref extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Cross references'),
-      'field types' => array('chado_linker__dbxref'),
-      'description' => t('This record can be cross referenced with a record
-          in another online database. This field is intended for the most
-          prominent reference.  At a minimum, the database and accession
-          must be provided.'),
+      'chado_linker__dbxref_widget' => array(
+        'label' => t('Cross references'),
+        'field types' => array('chado_linker__dbxref'),
+        'description' => t('This record can be cross referenced with a record
+            in another online database. This field is intended for the most
+            prominent reference.  At a minimum, the database and accession
+            must be provided.'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Cross references'),
-      'field types' => array('chado_linker__dbxref'),
-      'settings' => array(
+      'chado_linker__dbxref_formatter' => array(
+        'label' => t('Cross references'),
+        'field types' => array('chado_linker__dbxref'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     $chado_table = $field['settings']['chado_table'];
@@ -169,9 +174,9 @@ class chado_linker__dbxref extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $field_name = $field['field_name'];

+ 43 - 38
tripal_chado/includes/fields/chado_linker__expression.inc

@@ -3,9 +3,9 @@
 class chado_linker__expression extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Expression'),
       'description' => t('Associates an expression with
@@ -23,33 +23,34 @@ class chado_linker__expression extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $expression_table = $table_name . '_expression';
     if (chado_table_exists($expression_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $schema = chado_get_schema('featureloc');
     $pkey = $schema['primary key'][0];
@@ -71,23 +72,23 @@ class chado_linker__expression extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '_expression',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Expression',
       'description' => 'Information about the expression of this record.',
       'required' => FALSE,
@@ -111,31 +112,35 @@ class chado_linker__expression extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
- function widget_info() {
+ public static function widgetInfo() {
     return array(
-      'label' => t('Expressions'),
-      'field types' => array('chado_linker__expression'),
+      'chado_linker__expression_widget' => array(
+        'label' => t('Expressions'),
+        'field types' => array('chado_linker__expression'),
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Expression'),
-      'field types' => array('chado_linker__expression'),
-      'settings' => array(
+      'chado_linker__expression_formatter' => array(
+        'label' => t('Expression'),
+        'field types' => array('chado_linker__expression'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     // Get the settings

+ 45 - 40
tripal_chado/includes/fields/chado_linker__featureloc.inc

@@ -3,9 +3,9 @@
 class chado_linker__featureloc extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Aligned Locations'),
       'description' => t('Locations on landmark sequences where the feature is aligned.'),
@@ -22,31 +22,32 @@ class chado_linker__featureloc extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If  this is not the feature table then we don't want to attach.
     if ($table_name == 'feature') {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $schema = chado_get_schema('featureloc');
     $pkey = $schema['primary key'][0];
@@ -68,23 +69,23 @@ class chado_linker__featureloc extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'featureloc',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Aligned Locations',
       'description' => 'The locations on other genomic sequences where this
         record has been aligned.',
@@ -109,23 +110,27 @@ class chado_linker__featureloc extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  public function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Aligned Locations'),
-      'field types' => array('chado_linker__featureloc')
+      'chado_linker__featureloc_widget' => array(
+        'label' => t('Aligned Locations'),
+        'field types' => array('chado_linker__featureloc')
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Aligned Locations'),
-      'field types' => array('chado_linker__featureloc'),
-      'settings' => array(
+      'chado_linker__featureloc_formatter' => array(
+        'label' => t('Aligned Locations'),
+        'field types' => array('chado_linker__featureloc'),
+        'settings' => array(
+        ),
       ),
     );
   }
@@ -149,9 +154,9 @@ class chado_linker__featureloc extends TripalField {
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity,
+  static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     // Get the settings
@@ -405,9 +410,9 @@ class chado_linker__featureloc extends TripalField {
    }
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-   public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+   public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
   }

+ 45 - 40
tripal_chado/includes/fields/chado_linker__genotype.inc

@@ -3,9 +3,9 @@
 class chado_linker__genotype extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Genotypes'),
       'description' => t('Associates an indviddual or organization with
@@ -21,55 +21,60 @@ class chado_linker__genotype extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Genotypes'),
-      'field types' => array('chado_linker__genotype'),
+      'chado_linker__genotype_widget' => array(
+        'label' => t('Genotypes'),
+        'field types' => array('chado_linker__genotype'),
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Genotypes'),
-      'field types' => array('chado_linker__genotype'),
-      'settings' => array(
+      'chado_linker__genotype_formatter' => array(
+        'label' => t('Genotypes'),
+        'field types' => array('chado_linker__genotype'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $genotype_table = $table_name . '_genotype';
     if (chado_table_exists($genotype_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $genotype_table = $table_name . '_genotype';
     $schema = chado_get_schema($genotype_table);
@@ -92,23 +97,23 @@ class chado_linker__genotype extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__genotype',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Genotypes',
       'description' => 'The genotypes associated with this record.',
       'required' => FALSE,
@@ -132,9 +137,9 @@ class chado_linker__genotype extends TripalField {
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
 
     // Get the settings
@@ -188,9 +193,9 @@ class chado_linker__genotype extends TripalField {
 
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
   }

+ 45 - 40
tripal_chado/includes/fields/chado_linker__phenotype.inc

@@ -3,9 +3,9 @@
 class chado_linker__phenotype extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Phenotypes'),
       'description' => t('Associates an indviddual or organization with
@@ -21,55 +21,60 @@ class chado_linker__phenotype extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Phenotypes'),
-      'field types' => array('chado_linker__phenotype'),
+      'chado_linker__phenotype_widget' => array(
+        'label' => t('Phenotypes'),
+        'field types' => array('chado_linker__phenotype'),
+      ),
     );
   }
 
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Phenotypes'),
-      'field types' => array('chado_linker__phenotype'),
-      'settings' => array(
+      'chado_linker__phenotype_formatter' => array(
+        'label' => t('Phenotypes'),
+        'field types' => array('chado_linker__phenotype'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $phenotype_table = $table_name . '_phenotype';
     if (chado_table_exists($phenotype_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $phenotype_table = $table_name . '_phenotype';
     $schema = chado_get_schema($phenotype_table);
@@ -92,23 +97,23 @@ class chado_linker__phenotype extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__phenotype',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Phenotypes',
       'description' => 'The phenotypes associated with this record.',
       'required' => FALSE,
@@ -133,9 +138,9 @@ class chado_linker__phenotype extends TripalField {
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  public function formatter_view(&$element, $entity_type, $entity,
+  public static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
@@ -188,9 +193,9 @@ class chado_linker__phenotype extends TripalField {
 
 
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
   }

+ 27 - 33
tripal_chado/includes/fields/chado_linker__prop.inc

@@ -2,9 +2,9 @@
 
 class chado_linker__prop extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Add a Property'),
       'description' => t('Add details about this property.'),
@@ -21,15 +21,15 @@ class chado_linker__prop extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
+  protected function setCanAttach() {
     // This field is only attached by the chado_linker__prop_addr field.
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
@@ -37,10 +37,10 @@ class chado_linker__prop extends TripalField {
 
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
@@ -48,39 +48,33 @@ class chado_linker__prop extends TripalField {
 
   }
   /**
-   * @see TripalField::attach_info()
+   * @see TripalField::widgetInfo()
    */
-  function attach_info($entity_type, $bundle, $target) {
-    $field_info = array();
-
-    // This field is only attached by the chado_linker__prop_addr field.
-
-    return $field_info;
-  }
-  /**
-   * @see TripalField::widget_info()
-   */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Property'),
-      'field types' => array('chado_linker__prop'),
+      'chado_linker__prop_widget' => array(
+        'label' => t('Property'),
+        'field types' => array('chado_linker__prop'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Property'),
-      'field types' => array('chado_linker__prop'),
-      'settings' => array(
+      'chado_linker__prop_formatter' => array(
+        'label' => t('Property'),
+        'field types' => array('chado_linker__prop'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
     $field_name = $field['field_name'];
@@ -100,9 +94,9 @@ class chado_linker__prop extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];
@@ -184,7 +178,7 @@ class chado_linker__prop extends TripalField {
   /**
    * @see TripalField::validate()
    */
-  function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
+  static function widgetFormValidate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
     $field_name = $element['#field_name'];
     $delta = $element['#delta'];
     $entity = $element['#entity'];

+ 39 - 36
tripal_chado/includes/fields/chado_linker__prop_adder.inc

@@ -2,9 +2,9 @@
 
 class chado_linker__prop_adder extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Add a Property Type'),
       'description' => t('This record may have any number of properties. Use
@@ -23,33 +23,34 @@ class chado_linker__prop_adder extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $prop_table = $table_name . 'prop';
     if (chado_table_exists($prop_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $prop_table = $table_name . 'prop';
     return array(
@@ -65,24 +66,24 @@ class chado_linker__prop_adder extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->canAttach()) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $prop_table = $table_name . 'prop';
     return array(
       'field_name' => $prop_table,
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Add Properties',
       'description' => 'Add additional property types to this record.',
       'required' => FALSE,
@@ -105,18 +106,20 @@ class chado_linker__prop_adder extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Add a Property'),
-      'field types' => array('chado_linker__prop_adder'),
+      'chado_linker__prop_adder_widget' => array(
+        'label' => t('Add a Property'),
+        'field types' => array('chado_linker__prop_adder'),
+      ),
     );
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  function widget_form(&$widget, &$form, &$form_state,
+  static function widgetForm(&$widget, &$form, &$form_state,
       $field, $instance, $langcode, $items, $delta, $element) {
 
     // This field has no value field.  Just a fieldset for adding new properties.
@@ -219,10 +222,10 @@ function chado_linker__prop_adder_widget_validate($element, &$form_state) {
               !array_key_exists('TripalEntity', $field['bundles']) or
               !in_array($bundle_name, $field['bundles']['TripalEntity'])) {
 
-            $create_instance_info = array(
+            $createInstanceInfo = array(
               'field_name' => 'property-' . $term[0]->cvterm_id,
               'entity_type' => 'TripalEntity',
-              'bundle' => $bundle->name,
+              'bundle' => $this->bundle->name,
               'label' => ucfirst(preg_replace('/_/', ' ', $term[0]->name)),
               'description' => $term[0]->definition ? $term[0]->definition : '',
               'required' => FALSE,
@@ -241,7 +244,7 @@ function chado_linker__prop_adder_widget_validate($element, &$form_state) {
                 ),
               ),
             );
-            $instance = field_create_instance($create_instance_info);
+            $instance = field_create_instance($createInstanceInfo);
           }
         }
         else if (count($term) > 1) {

+ 45 - 40
tripal_chado/includes/fields/chado_linker__pub.inc

@@ -2,9 +2,9 @@
 
 class chado_linker_pub extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Publications'),
       'description' => t('Associates a publication (e.g. journal article,
@@ -22,33 +22,34 @@ class chado_linker_pub extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $pub_table = $table_name . '_pub';
     if (chado_table_exists($pub_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $pub_table = $table_name . '_pub';
     $schema = chado_get_schema($pub_table);
@@ -70,23 +71,23 @@ class chado_linker_pub extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '__pub',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Publications',
       'description' => 'This record has been referenced or is sourced from
         these publications.',
@@ -111,29 +112,33 @@ class chado_linker_pub extends TripalField {
 
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Publications'),
-      'field types' => array('chado_linker__pub'),
+      'chado_linker__pub_widget' => array(
+        'label' => t('Publications'),
+        'field types' => array('chado_linker__pub'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Publications'),
-      'field types' => array('chado_linker__pub'),
-      'settings' => array(
+      'chado_linker__pub_formatter' => array(
+        'label' => t('Publications'),
+        'field types' => array('chado_linker__pub'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     $list_items = array();
@@ -162,9 +167,9 @@ class chado_linker_pub extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];

+ 45 - 40
tripal_chado/includes/fields/chado_linker__relationship.inc

@@ -2,9 +2,9 @@
 
 class chado_linker__relationship extends TripalField {
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Relationships'),
       'description' => t('Relationships between records.'),
@@ -21,32 +21,33 @@ class chado_linker__relationship extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $rel_table = $table_name . '_relationship';
     if (chado_table_exists($rel_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $rel_table = $table_name . '_relationship';
     $schema = chado_get_schema($rel_table);
@@ -68,23 +69,23 @@ class chado_linker__relationship extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '_relationship',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Relationships',
       'description' => 'Other records with relationships to this record.',
       'required' => FALSE,
@@ -108,30 +109,34 @@ class chado_linker__relationship extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Relationship Settings'),
-      'field types' => array('chado_linker__relationship')
+      'chado_linker__relationship_widget' => array(
+        'label' => t('Relationship Settings'),
+        'field types' => array('chado_linker__relationship')
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Relationships'),
-      'field types' => array('chado_linker__relationship'),
-      'settings' => array(
+      'chado_linker__relationship_formatter' => array(
+        'label' => t('Relationships'),
+        'field types' => array('chado_linker__relationship'),
+        'settings' => array(
+        ),
       ),
     );
   }
 
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity,
+  static function formatterView(&$element, $entity_type, $entity,
       $field, $instance, $langcode, $items, $display) {
     // Get the settings
     $settings = $display['settings'];
@@ -209,9 +214,9 @@ class chado_linker__relationship extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  static function  widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $field_name = $field['field_name'];

+ 45 - 40
tripal_chado/includes/fields/chado_linker__synonym.inc

@@ -3,9 +3,9 @@
 class chado_linker__synonym extends TripalField {
 
   /**
-   * @see TripalField::field_info()
+   * @see TripalField::fieldInfo()
    */
-  function field_info() {
+  static function fieldInfo() {
     return array(
       'label' => t('Synonyms'),
       'description' => t('Adds an alternative name (synonym or alias) to this record.'),
@@ -22,33 +22,34 @@ class chado_linker__synonym extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  protected function can_attach($entity_type, $bundle, $details) {
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach() {
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     // If the linker table does not exists then we don't want to add attach.
     $syn_table = $table_name . '_synonym';
     if (chado_table_exists($syn_table)) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $syn_table = $table_name . '_synonym';
     $schema = chado_get_schema($syn_table);
@@ -71,23 +72,23 @@ class chado_linker__synonym extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => $table_name . '_synonym',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Synonyms',
       'description' => 'Alternate names, aliases or synonyms for this record.',
       'required' => FALSE,
@@ -110,29 +111,33 @@ class chado_linker__synonym extends TripalField {
     );
   }
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Synonyms'),
-      'field types' => array('chado_linker__synonym'),
+      'chado_linker__synonym_widget' => array(
+        'label' => t('Synonyms'),
+        'field types' => array('chado_linker__synonym'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  function formatter_info() {
+  static function formatterInfo() {
     return array(
-      'label' => t('Synonyms'),
-      'field types' => array('chado_linker__synonym'),
-      'settings' => array(
+      'chado_linker__synonym_formatter' => array(
+        'label' => t('Synonyms'),
+        'field types' => array('chado_linker__synonym'),
+        'settings' => array(
+        ),
       ),
     );
   }
   /**
-   * @see TripalField::formatter_view()
+   * @see TripalField::formatterView()
    */
-  function formatter_view(&$element, $entity_type, $entity, $field,
+  static function formatterView(&$element, $entity_type, $entity, $field,
       $instance, $langcode, $items, $display) {
 
     $chado_table = $field['settings']['chado_table'];
@@ -152,9 +157,9 @@ class chado_linker__synonym extends TripalField {
     }
   }
   /**
-   * @see TripalField::widget_form()
+   * @see TripalField::widgetForm()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $entity = $form['#entity'];

+ 41 - 36
tripal_chado/includes/fields/chado_organism__type_id.inc

@@ -5,7 +5,7 @@ class chado_organism__type_id extends TripalField {
   /**
    * @see TripalField::info()
    */
-  public function field_info() {
+  public static function fieldInfo() {
     return array(
       'label' => t('Infraspecific Type'),
       'description' => t('A field for specifying an infraspecific type.'),
@@ -23,34 +23,35 @@ class chado_organism__type_id extends TripalField {
   /**
    * @see TripalField::can_attach()
    */
-  function can_attach($entity_type, $bundle, $details){
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+  protected function setCanAttach(){
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     $schema = chado_get_schema($table_name);
 
     // If this is the organism table and Chado v1.3 then attach.
     if ($table_name == 'organism' and array_key_exists('type_id', $schema['fields'])) {
-      return TRUE;
+      $this->can_attach = TRUE;
+      return;
     }
-    return FALSE;
+    $this->can_attach = FALSE;
   }
   /**
    * @see TripalField::create_info()
    */
-  function create_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'organism__type_id',
@@ -68,23 +69,23 @@ class chado_organism__type_id extends TripalField {
     );
   }
   /**
-   * @see TripalField::create_instance_info()
+   * @see TripalField::createInstanceInfo()
    */
-  function create_instance_info($entity_type, $bundle, $details) {
-    if (!$this->can_attach($entity_type, $bundle, $details)) {
+  function createInstanceInfo() {
+    if (!$this->can_attach) {
       return;
     }
 
-    $table_name = $details['chado_table'];
-    $type_table = $details['chado_type_table'];
-    $type_field = $details['chado_type_column'];
-    $cv_id      = $details['chado_cv_id'];
-    $cvterm_id  = $details['chado_cvterm_id'];
+    $table_name = $this->details['chado_table'];
+    $type_table = $this->details['chado_type_table'];
+    $type_field = $this->details['chado_type_column'];
+    $cv_id      = $this->details['chado_cv_id'];
+    $cvterm_id  = $this->details['chado_cvterm_id'];
 
     return array(
       'field_name' => 'organism__type_id',
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
+      'entity_type' => $this->entity_type,
+      'bundle' => $this->bundle->name,
       'label' => 'Infrapsecific Type',
       'description' => 'The Infrapsecific Type.',
       'required' => FALSE,
@@ -108,22 +109,26 @@ class chado_organism__type_id extends TripalField {
   }
 
   /**
-   * @see TripalField::widget_info()
+   * @see TripalField::widgetInfo()
    */
-  public function widget_info() {
+  public static function widgetInfo() {
     return array(
-      'label' => t('Infraspecific Type'),
-      'field types' => array('chado_organism__type_id')
+      'chado_organism__type_id_widget' => array(
+        'label' => t('Infraspecific Type'),
+        'field types' => array('chado_organism__type_id'),
+      ),
     );
   }
   /**
-   * @see TripalField::formatter_info()
+   * @see TripalField::formatterInfo()
    */
-  public function formatter_info() {
+  public static function formatterInfo() {
     return array(
-      'label' => t('Infraspecific Type'),
-      'field types' => array('chado_organism__type_id'),
-      'settings' => array(
+      'chado_organism__type_id_formatter' => array(
+        'label' => t('Infraspecific Type'),
+        'field types' => array('chado_organism__type_id'),
+        'settings' => array(
+        ),
       ),
     );
   }
@@ -131,7 +136,7 @@ class chado_organism__type_id extends TripalField {
   /**
    * @see TripalField::widget()
    */
-  public function widget_form(&$widget, &$form, &$form_state, $field, $instance,
+  public static function widgetForm(&$widget, &$form, &$form_state, $field, $instance,
       $langcode, $items, $delta, $element) {
 
     $settings = $field['settings'];

+ 12 - 1
tripal_chado/includes/tripal_chado.entity.inc

@@ -9,7 +9,18 @@
  * @param $bundle
  *  The TripalBundle object.
  */
-function triipal_chado_bundle_create(&$bundle) {
+
+function tripal_chado_bundle_create($bundle) {
+  tripal_chado_set_bundle_vars($bundle);
+}
+
+/**
+ * Associates the Chado table/column with the bundle.
+ *
+ * @param $bundle
+ *   The TripalBundle object.
+ */
+function tripal_chado_set_bundle_vars($bundle) {
   // The details array is used to pass to the TripalEntity->create_info()
   // function to provide more details about how the bundle is used by this
   // module.

+ 54 - 118
tripal_chado/includes/tripal_chado.fields.inc

@@ -17,18 +17,9 @@
 function tripal_chado_field_info() {
   $info = array();
 
-  // Find all of the files in the tripal_chado/includes/fields directory.
-  $fields_path = drupal_get_path('module', 'tripal_chado') . '/includes/fields';
-  $field_files = file_scan_directory($fields_path, '/^chado_.*\.inc$/');
-
-  // Iterate through the fields, include the file and run the info function.
-  foreach ($field_files as $file) {
-    $field_type = $file->name;
-    module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-    if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $info[$field_type] = $field_obj->field_info();
-    }
+  $field_types = tripal_get_field_types('tripal_chado');
+  foreach ($field_types as $field_type) {
+    $info[$field_type] = $field_type::fieldInfo();
   }
   return $info;
 
@@ -40,7 +31,7 @@ function tripal_chado_field_info() {
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_field_create_info($entity_type, $bundle, $term) {
+function tripal_chado_field_create_info($entity_type, $bundle) {
 
   // Get the details about the mapping of this bundle to the Chado table:
   $details = array(
@@ -72,21 +63,11 @@ function tripal_chado_field_create_info($entity_type, $bundle, $term) {
  */
 function tripal_chado_field_create_info_custom($entity_type, $bundle, $details) {
   $info = array();
-
-  // Find all of the files in the tripal_chado/includes/fields directory.
-  $fields_path = drupal_get_path('module', 'tripal_chado') . '/includes/fields';
-  $field_files = file_scan_directory($fields_path, '/^chado_.*\.inc$/');
-
-  // Iterate through the fields, include the file and run the info function.
-  foreach ($field_files as $file) {
-    $field_type = $file->name;
-    module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-    if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $result = $field_obj->create_info($entity_type, $bundle, $details);
-      if (is_array($result)) {
-        $info[$result['field_name']] = $result;
-      }
+  $fields = tripal_get_fields('tripal_chado', $entity_type, $bundle, $details);
+  foreach ($fields as $field) {
+    $field_name = $field->getFieldName();
+    if ($field->canAttach()) {
+      $info[$field_name] = $field->createInfo();
     }
   }
   return $info;
@@ -125,7 +106,7 @@ function tripal_chado_field_create_base($step, $entity_type, $bundle, $details)
   // created for each one. If not, then create them.
   $schema = chado_get_schema($table_name);
   if (!$schema) {
-    return $fields();
+    return $fields;
   }
 
   $columns = $schema['fields'];
@@ -278,7 +259,7 @@ function tripal_chado_field_create_info_base_defaults($field_name, $table_name,
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
  */
-function tripal_chado_field_create_instance_info($entity_type, $bundle, $term) {
+function tripal_chado_field_create_instance_info($entity_type, $bundle) {
 
   // Get the details about the mapping of this bundle to the Chado table:
   $details = array(
@@ -473,21 +454,11 @@ function tripal_chado_field_create_instance_info_base_defaults($bundle_name,
  */
 function tripal_chado_field_create_instance_info_custom($entity_type, $bundle, $details) {
   $info = array();
-
-  // Find all of the files in the tripal_chado/includes/fields directory.
-  $fields_path = drupal_get_path('module', 'tripal_chado') . '/includes/fields';
-  $field_files = file_scan_directory($fields_path, '/^chado_.*\.inc$/');
-
-  // Iterate through the fields, include the file and run the info function.
-  foreach ($field_files as $file) {
-    $field_type = $file->name;
-    module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-    if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $result = $field_obj->create_instance_info($entity_type, $bundle, $details);
-      if (is_array($result)) {
-        $info[$result['field_name']] = $result;
-      }
+  $fields = tripal_get_fields('tripal_chado', $entity_type, $bundle, $details);
+  foreach ($fields as $field) {
+    $field_name = $field->getFieldName();
+    if ($field->canAttach()) {
+      $info[$field_name] = $field->createInstanceInfo();
     }
   }
   return $info;
@@ -502,20 +473,13 @@ function tripal_chado_field_create_instance_info_custom($entity_type, $bundle, $
  * all of the code for a single field to be self contained in a single file.
  */
 function tripal_chado_field_widget_info() {
-  $widgets = array();
+  $info = array();
 
-  $fields = field_info_fields();
-  foreach ($fields as $field) {
-    $field_type = $field['type'];
-    if ($field['storage']['type'] == 'field_chado_storage') {
-      module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-      if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-        $field_obj = new $field_type();
-        $widgets[$field_type . '_widget'] = $field_obj->widget_info();
-      }
-    }
+  $field_types = tripal_get_field_types('tripal_chado');
+  foreach ($field_types as $field_type) {
+    $info += $field_type::widgetInfo();
   }
-  return $widgets;
+  return $info;
 }
 /**
  * Implements hook_field_formatter_info().
@@ -526,33 +490,24 @@ function tripal_chado_field_widget_info() {
  * all of the code for a single field to be self contained in a single file.
  */
 function tripal_chado_field_formatter_info() {
-  $formatters = array();
+  $info = array();
 
-  $fields = field_info_fields();
-  foreach ($fields as $field) {
-    $field_type = $field['type'];
-    if ($field['storage']['type'] == 'field_chado_storage') {
-      module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-      if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-        $field_obj = new $field_type();
-        $formatters[$field_type . '_formatter'] = $field_obj->formatter_info();
-      }
-    }
+  $field_types = tripal_get_field_types('tripal_chado');
+  foreach ($field_types as $field_type) {
+    $info += $field_type::formatterInfo();
   }
-  return $formatters;
+  return $info;
 }
 
 /**
  * Implements hook_field_settings_form()
  */
 function tripal_chado_field_settings_form($field, $instance, $has_data) {
-  $form = '';
+  $form = array();
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-
-  if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-    $field_obj = new $field_type();
-    $form = $field_obj->settings_form($field, $instance, $has_data);
+  if (class_exists($field_type)) {
+    $form = $field_type::settingsForm($field, $instance, $has_data);
   }
   return $form;
 }
@@ -564,10 +519,8 @@ function tripal_chado_field_formatter_settings_summary($field, $instance, $view_
   $summary = '';
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-
-  if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-    $field = new $field_type();
-    $summary = $field->formatter_settings_summary($field, $instance, $view_mode);
+  if (class_exists($field_type)) {
+    $form = $field_type::formatterSettingsSummary($field, $instance, $view_mode);
   }
   return $summary;
 }
@@ -577,23 +530,14 @@ function tripal_chado_field_formatter_settings_summary($field, $instance, $view_
  */
 function tripal_chado_field_formatter_settings_form($field, $instance,
     $view_mode, $form, &$form_state) {
-  $element = array();
 
+  $form = array();
   $field_type = $field['type'];
-  form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/' . $field_type);
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-
-  if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-    $field_obj = new $field_type();
-     $element = $field_obj->formatter_settings_form($field, $instance, $view_mode, $form, $form_state);
+  if (class_exists($field_type)) {
+    $form = $field_type::formatterSettingsForm(field, $instance, $view_mode, $form, $form_state);
   }
-
-  $function = $field_type . '_formatter_settings_form';
-  if (function_exists($function)) {
-    $element = $function($field, $instance, $view_mode, $form, $form_state);
-  }
-
-  return $element;
+  return $form;
 }
 
 
@@ -607,12 +551,9 @@ function tripal_chado_field_formatter_view($entity_type, $entity, $field,
   $element = array();
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-
-  if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-    $field_obj = new $field_type();
-    $field_obj->formatter_view($element, $entity_type, $entity, $field, $instance, $langcode, $items, $display);
+  if (class_exists($field_type)) {
+    $field_type::formatterView($element, $entity_type, $entity, $field, $instance, $langcode, $items, $display);
   }
-
   return $element;
 }
 
@@ -623,18 +564,14 @@ function tripal_chado_field_widget_form(&$form, &$form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
 
   $widget = $element;
-
-  $field_name = $instance['field_name'];
   $field_type = $field['type'];
-  form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/' . $field_type);
-  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_name);
-
-  if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-    $field_obj = new $field_type();
-    $field_obj->widget_form($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  if (class_exists($field_type)) {
+    $field_type::widgetForm($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
   }
-
   return $widget;
+
+
 }
 
 
@@ -678,31 +615,30 @@ function tripal_chado_field_widget_form_alter(&$element, &$form_state, $context)
  */
 function tripal_chado_field_validate($entity_type, $entity, $field, $instance,
      $langcode, $items, &$errors) {
+
   $field_type = $field['type'];
-  if ($field['storage']['type'] == 'field_chado_storage') {
-    module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-    if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $field_obj->validate($entity_type, $entity, $field, $instance,
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  if (class_exists($field_type)) {
+    $field_obj = new $field_type($entity_type, $entity->bundle);
+    $form = $field_obj::widgetFormValidate($entity_type, $entity, $field, $instance,
         $langcode, $items, $errors);
-    }
   }
 }
 
 /**
  * Implements hook_field_validate()
+ *
+ * This is a TripalEntity specific hook.
  */
 function tripal_chado_field_submit($entity_type, $entity, $field, $instance,
     $langcode, &$items, $form, &$form_state) {
 
   $field_type = $field['type'];
-  if ($field['storage']['type'] == 'field_chado_storage') {
-    module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
-    if (preg_match('/^chado/', $field_type) and class_exists($field_type)) {
-      $field_obj = new $field_type();
-      $field_obj->submit($entity_type, $entity, $field, $instance,
-          $langcode, $items, $form, $form_state);
-    }
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  if (class_exists($field_type)) {
+    $field_obj = new $field_type($entity_type, $entity->bundle);
+    $form = $field_obj::widgetFormSubmit($entity_type, $entity, $field, $instance,
+        $langcode, $items, $errors);
   }
 }