Skip to content

Commit

Permalink
Quick Fix to fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson committed Feb 12, 2019
1 parent b960d39 commit 373bc29
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class local__genotype_matrix_link_formatter extends ChadoFieldFormatter {
public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {

// Retrieve the current settings not handled by our parent.
$settings = $this->instance['display'][$view_mode]['settings'];
$settings = $display['settings'];
$our_setting_keys = array('help_text', 'button_text');
foreach ($our_setting_keys as $k) {
if (!isset($settings[$k])) { $settings[$k] = self::$default_settings[$k]; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ class local__marker_genotype_summary extends ChadoField {
* value of the field.
*/
public function load($entity) {
// THIS FIELD MUST CONTAIN DATA IN ORDER FOR THE FORMATTER TO BE RENDERED.
$field_name = $this->instance['field_name'];

// ChadoFields automatically load the chado column specified in the
// default settings above. If that is all you need then you don't even
Expand All @@ -158,7 +160,7 @@ class local__marker_genotype_summary extends ChadoField {
'"Marker Genotype Summary" field was unable to determine what the organism is for entity :id.',
array( ':id' => $entity->id, )
);
$entity->local__marker_genotype_summary['und'][0]['value'] = FALSE;
$entity->{$field_name}['und'][0]['value'] = FALSE;
return FALSE;
}

Expand All @@ -175,21 +177,21 @@ class local__marker_genotype_summary extends ChadoField {
// If there are no genotypes attached to this marker, we would like to
// indicate that the genotype summary should be empty.
if (empty($variant)) {
$entity->local__marker_genotype_summary['und'][0]['value'] = array();
$entity->{$field_name}['und'][0]['value'] = array();
}
else {
$marker_name = $variant['markers'][$marker_id];

// First store information about the marker so we can lebel the donut/ring.
$entity->local__marker_genotype_summary['und'][0]['value'] = array();
$entity->local__marker_genotype_summary['und'][0]['value']['rdfs:label'] = $marker_name;
$entity->local__marker_genotype_summary['und'][0]['value']['SO:0001645'] = $marker_name;
$entity->local__marker_genotype_summary['und'][0]['value']['hydra:member'] = array();
$entity->{$field_name}['und'][0]['value'] = array();
$entity->{$field_name}['und'][0]['value']['rdfs:label'] = $marker_name;
$entity->{$field_name}['und'][0]['value']['SO:0001645'] = $marker_name;
$entity->{$field_name}['und'][0]['value']['hydra:member'] = array();

// Then store information about each allele so we can draw/label each
// part or pie piece of the donut/ring.
foreach ($variant['marker_alleles'][$marker_id] as $d) {
$entity->local__marker_genotype_summary['und'][0]['value']['hydra:member'][] = array(
$entity->{$field_name}['und'][0]['value']['hydra:member'][] = array(
'SO:0001023' => $d['allele'],
'rdfs:label' => $d['allele'],
'local:count' => $d['num_germplasm'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class local__sequence_with_variants extends ChadoField {
*
*/
public function load($entity) {
// THIS FIELD MUST CONTAIN DATA IN ORDER FOR THE FORMATTER TO BE RENDERED.
$field_name = $this->instance['field_name'];

// Placeholder for the value of this field.
// Populating this is just cleaner code-wise then populating the entity
// directly. At the end this will be assigned to
Expand All @@ -150,7 +153,7 @@ class local__sequence_with_variants extends ChadoField {
$settings = $this->instance['settings'];

// First, retrieve the chado feature_id for the current Tripal Content.
$feature_id = $entity->local__sequence_with_variants['und'][0]['chado-feature__feature_id'];
$feature_id = $entity->{$field_name}['und'][0]['chado-feature__feature_id'];

// Ensure we have a $variant_id and $marker_id set based on what we are attached to.
// - Attached to a Variant.
Expand All @@ -177,7 +180,7 @@ class local__sequence_with_variants extends ChadoField {
'"Sequence with Variants" field was unable to determine what the organism for entity :id is.',
array( ':id' => $entity->id, )
);
$entity->local__sequence_with_variants['und'][0]['value'] = FALSE;
$entity->{$field_name}['und'][0]['value'] = FALSE;
return FALSE;
}

Expand All @@ -192,7 +195,7 @@ class local__sequence_with_variants extends ChadoField {
// If there are no locations on parents with sequence then unfortunalty
// we cannot provide this display...
if (!$locations) {
$entity->local__sequence_with_variants['und'][0]['value'] = FALSE;
$entity->{$field_name}['und'][0]['value'] = FALSE;
return FALSE;
}

Expand Down Expand Up @@ -284,7 +287,7 @@ class local__sequence_with_variants extends ChadoField {
}

// Finally assign the value to the entity.
$entity->local__sequence_with_variants['und'][0]['value'] = $value;
$entity->{$field_name}['und'][0]['value'] = $value;
//@debug dpm($value, 'value in load');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class local__variant_genotype_summary extends ChadoField {
*
*/
public function load($entity) {
// THIS FIELD MUST CONTAIN DATA IN ORDER FOR THE FORMATTER TO BE RENDERED.
$field_name = $this->instance['field_name'];

// ChadoFields automatically load the chado column specified in the
// default settings above. If that is all you need then you don't even
Expand All @@ -147,7 +149,7 @@ class local__variant_genotype_summary extends ChadoField {
parent::load($entity);

// First, retrieve the chado feature_id/variant_id for the current Tripal Content, as we requested.
$variant_id = $entity->local__variant_genotype_summary['und'][0]['chado-feature__feature_id'];
$variant_id = $entity->{$field_name}['und'][0]['chado-feature__feature_id'];

// Retrieve the data using the api.
$variant = NULL;
Expand All @@ -168,7 +170,7 @@ class local__variant_genotype_summary extends ChadoField {
// If there are no genotypes attached to this variant, we would like to
// indicate that the genotype summary should be empty.
if (empty($variant)) {
$entity->local__variant_genotype_summary['und'][0]['value'] = array();
$entity->{$field_name}['und'][0]['value'] = array();
}
else {
// For each marker attached to this variant, add an item to the field.
Expand All @@ -179,15 +181,15 @@ class local__variant_genotype_summary extends ChadoField {
$marker_name = $variant['markers'][$marker_id];

// First store information about the marker so we can lebel the donut/ring.
$entity->local__variant_genotype_summary['und'][$i]['value'] = array();
$entity->local__variant_genotype_summary['und'][$i]['value']['rdfs:label'] = $marker_name;
$entity->local__variant_genotype_summary['und'][$i]['value']['SO:0001645'] = $marker_name;
$entity->local__variant_genotype_summary['und'][$i]['value']['hydra:member'] = array();
$entity->{$field_name}['und'][$i]['value'] = array();
$entity->{$field_name}['und'][$i]['value']['rdfs:label'] = $marker_name;
$entity->{$field_name}['und'][$i]['value']['SO:0001645'] = $marker_name;
$entity->{$field_name}['und'][$i]['value']['hydra:member'] = array();

// Then store information about each allele so we can draw/label each
// part or pie piece of the donut/ring.
foreach ($alleles as $d) {
$entity->local__variant_genotype_summary['und'][$i]['value']['hydra:member'][] = array(
$entity->{$field_name}['und'][$i]['value']['hydra:member'][] = array(
'SO:0001023' => $d['allele'],
'rdfs:label' => $d['allele'],
'local:count' => $d['num_germplasm'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class so__genetic_marker extends ChadoField {
*/
public function load($entity) {
global $base_url;
$field_name = $this->field['field_name'];

// THIS FIELD MUST CONTAIN DATA IN ORDER FOR THE FORMATTER TO BE RENDERED.
$field_name = $this->instance['field_name'];

// ChadoFields automatically load the chado column specified in the
// default settings above. If that is all you need then you don't even
Expand Down

0 comments on commit 373bc29

Please sign in to comment.