public function sep__protocol::load

3.x sep__protocol.inc public sep__protocol::load($entity)

Loads the field values from the underlying data store.

Parameters

$entity:

Return value

An array of the following format: $entity->{$field_name}['und'][0]['value'] = $value; where:

  • $entity is the entity object to which this field is attached.
  • $field_name is the name of this field
  • 'und' is the language code (in this case 'und' == undefined)
  • 0 is the cardinality. Increment by 1 when more than one item is available.
  • 'value' is the key indicating the value of this field. It should always be set. The value of the 'value' key will be the contents used for web services and for downloadable content. The value should be of the follow format types: 1) A single value (text, numeric, etc.) 2) An array of key value pair. 3) If multiple entries then cardinality should incremented and format types 1 and 2 should be used for each item.

The array may contain as many other keys at the same level as 'value' but those keys are for internal field use and are not considered the value of the field.

Overrides TripalField::load

File

tripal_chado/includes/TripalFields/sep__protocol/sep__protocol.inc, line 108

Class

sep__protocol
@class Purpose: Provide a field for Protocol (typically the protocol_id column of a Chado table).

Code

public function load($entity) {

  parent::load($entity);


  $record = $entity->chado_record;
  $settings = $this->instance['settings'];


  $field_name = $this->field['field_name'];
  $field_type = $this->field['type'];
  $field_table = $this->instance['settings']['chado_table'];
  $field_column = $this->instance['settings']['chado_column'];
  $linker_field = 'chado-' . $field_table . '__protocol_id';

  // Set some defaults for the empty record.
  $entity->{$field_name}['und'][0] =[
  'value'[]
  ];

  if (!$record->protocol_id->protocol_id) {
    return;
  }

  $protocol_id = $record->protocol_id->protocol_id;
  $protocol_name = $record->protocol_id->name;

  $entity_id = $record->entity_id;

  $entity->{$field_name}['und'][0]['value'] =[
  "protocol_id" $protocol_id
    "protocol_name" $protocol_name
    "entity_id" $entity_id
    ];

  // Is there a published entity for this protocol?
  if (property_exists($record->{$field_column}, 'entity_id')) {
    $entity->{$field_name}['und'][0]['value']['entity_id'] = 'TripalEntity:' . $record->{$field_column}->entity_id;
  }
}