function tripal_chado_entity_create

3.x tripal_chado.entity.inc tripal_chado_entity_create(&$entity, $type)

Implements hook_entity_create().

This hook is called when brand new entities are created, but they are not loaded so the hook_entity_load() is not yet called. We can use this hook to add properties to the entity before saving.

File

tripal_chado/includes/tripal_chado.entity.inc, line 11

Code

function tripal_chado_entity_create(&$entity, $type) {
  if ($type == 'TripalEntity') {

    // Set some defaults on vars needed by this module.
    if (!property_exists($entity, 'chado_table')) {
      $entity->chado_table = NULL;
      $entity->chado_column = NULL;
      $entity->chado_linker = NULL;

      // Add in the Chado table information for this entity type.
      $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
      if ($bundle->data_table) {
        $entity->chado_table = $bundle->data_table;
        $entity->chado_column = $bundle->type_column;
        $entity->chado_linker = $bundle->type_linker_table;
      }
    }
    if (!property_exists($entity, 'chado_record')) {
      $entity->chado_record = NULL;
      $entity->chado_record_id = NULL;
    }
  }
}