Skip to content

Commit

Permalink
Merge pull request #1467 from tripal/tv4g1-issue1466-schema__addition…
Browse files Browse the repository at this point in the history
…al_type

Tripal 4 bugfix for  schema__additional_type field
  • Loading branch information
spficklin committed Apr 5, 2023
2 parents 0e3d666 + d853fc9 commit de2d307
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function defaultFieldSettings() {
$settings = parent::defaultFieldSettings();
// If a fixed value is set, then the field will will always use the
// same value and the user will not be allowed the change it using the
// widget. This is necessary content types that correspond to Chado
// widget. This is necessary for content types that correspond to Chado
// tables with a type_id that should always match the content type (e.g.
// gene).
$settings['fixed_value'] = FALSE;
Expand All @@ -68,13 +68,25 @@ public static function tripalTypes($field_definition) {
// Get the Chado table and column this field maps to.
$storage_settings = $field_definition->getSetting('storage_plugin_settings');
$base_table = $storage_settings['base_table'];
$type_table = $storage_settings['type_table'];
$type_column = $storage_settings['type_column'];
$type_table = $storage_settings['type_table'] ?? '';
$type_column = $storage_settings['type_column'] ?? '';

// If we don't have a base table then we're not ready to specify the
// properties for this field.
if (!$base_table or !$type_table) {
$record_id_term = 'SIO:000729';
return [
new ChadoIntStoragePropertyType($entity_type_id, self::$id, 'record_id', $record_id_term, [
'action' => 'store_id',
'drupal_store' => TRUE,
])
];
}

// Get the the connecting information about the base table and the
// the table where the type is stored. If the base table has a `type_id`
// column then the base table and the type table are the same. If the
// we are using a prop table to store the type_id then the type table and
// table where the type is stored. If the base table has a `type_id`
// column then the base table and the type table are the same. If we
// are using a prop table to store the type_id then the type table and
// base table will be different.
$chado = \Drupal::service('tripal_chado.database');
$schema = $chado->schema();
Expand Down Expand Up @@ -137,7 +149,7 @@ public static function tripalTypes($field_definition) {
'chado_column' => $type_column,
'empty_value' => 0
]);
// This fields needs the term name, idspace and accessession for proper
// This field needs the term name, idspace and accession for proper
// display of the type.
$properties[] = new ChadoVarCharStoragePropertyType($entity_type_id, self::$id, 'term_name', $name_term, 128, [
'action' => 'join',
Expand Down

0 comments on commit de2d307

Please sign in to comment.