Browse Source

Added more documentation.

Lacey Sanderson 6 years ago
parent
commit
1e8e257c43

+ 26 - 0
tests/TripalFieldTestHelper.php

@@ -144,7 +144,18 @@ class TripalFieldTestHelper {
   }
 
   /**
+   * Create a fake version of the $element parameter used in many field methods
+   * (e.g. TripalFieldWidget::form).
    *
+   * @param $delta
+   *   The delta for the $element you want to fake.
+   * @param $langcode
+   *   The language code for the field/widget. This should usually be LANGUAGE_NONE.
+   * @param $required
+   *   True if the widget is required and false otherwise.
+   *
+   * @return
+   *   A fake $element variable for use in testing.
    */
   public function mockElement($delta = 0, $langcode = LANGUAGE_NONE, $required = FALSE) {
     return [
@@ -172,7 +183,11 @@ class TripalFieldTestHelper {
   }
 
   /**
+   * Create a fake version of the create/edit content form with the
+   * current entity attached.
    *
+   * @return
+   *   A fake $form array for use in testing.
    */
   public function mockForm() {
     return [
@@ -182,7 +197,18 @@ class TripalFieldTestHelper {
   }
 
   /**
+   * Create a fake version of the create/edit content form_state
+   * with the current entity attached.
    *
+   * @param $delta
+   *   The delta for the $element you want to fake.
+   * @param $langcode
+   *   The language code for the field/widget. This should usually be LANGUAGE_NONE.
+   * @param $values
+   *    An array of values where the key is the form element name and the value is
+   *    the fake user submmitted value.
+   * @return
+   *   A fake $form_state array for use in testing.
    */
   public function mockFormState($delta = 0, $langcode = LANGUAGE_NONE, $values = NULL) {
     $form_state = [

+ 33 - 0
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship.inc

@@ -276,6 +276,14 @@ class sbo__relationship extends ChadoField {
 
   /**
    * Retrive the subject from the current relationship.
+   *
+   * @param $relationship
+   *   A single expanded relationship from a variable generated by chado_generate_var().
+   *   At a minimum, if will have a subject, object and type which should be expanded to
+   *   the appropriate type of record depending on the content type this widget
+   *   is attached to.
+   * @return
+   *   An array of information for the subject of the $relationship.
    */
   private function getRelationshipSubject($relationship) {
     $name = [];
@@ -325,6 +333,14 @@ class sbo__relationship extends ChadoField {
 
   /**
    * Retrieve the object from the current relationship.
+   *
+   * @param $relationship
+   *   A single expanded relationship from a variable generated by chado_generate_var().
+   *   At a minimum, if will have a subject, object and type which should be expanded to
+   *   the appropriate type of record depending on the content type this widget
+   *   is attached to.
+   * @return
+   *   An array of information for the object of the $relationship.
    */
   private function getRelationshipObject($relationship) {
     $name = [];
@@ -373,6 +389,23 @@ class sbo__relationship extends ChadoField {
     return $record;
   }
 
+  /**
+   * Load a specific relationship as indicated by $delta.
+   * This function is called by the load method below.
+   *
+   * Note: The relationship is loaded by adding it the the entitiy values.
+   *
+   * @param $relationship
+   *   A single expanded relationship from a variable generated by chado_generate_var().
+   *   At a minimum, if will have a subject, object and type which should be expanded to
+   *   the appropriate type of record depending on the content type this widget
+   *   is attached to.
+   * @param $entity
+   *   The entity the widget is attached to.
+   * @param $delta
+   *   An integer indicating the specific relationship to load. This is usually the rank
+   *   from the relationship table (if there is one).
+   */
   private function loadRelationship($relationship, &$entity, $delta) {
 
     $field_name = $this->field['field_name'];