Tripal
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | List of all members
Drupal\tripal_chado\TripalField\ChadoFieldItemBase Class Reference
Inheritance diagram for Drupal\tripal_chado\TripalField\ChadoFieldItemBase:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\TripalField\ChadoFieldItemBase:
Collaboration graph
[legend]

Public Member Functions

 storageSettingsFormBaseTableAjaxCallback ($form, &$form_state)
 
 storageSettingsFormLinkingMethodAjaxCallback ($form, &$form_state)
 
 isCompatible (TripalEntityType $entity_type)
 
- Public Member Functions inherited from Drupal\tripal\TripalField\TripalFieldItemBase
 fieldSettingsForm (array $form, FormStateInterface $form_state)
 
 storageSettingsForm (array &$form, FormStateInterface $form_state, $has_data)
 
 tripalStorageId ()
 
 tripalSave ($field_item, $field_name, $prop_types, $prop_values, $entity)
 
 tripalLoad ($field_item, $field_name, $prop_types, $prop_values, $entity)
 
 tripalClear ($field_item, $field_name, $prop_types, $prop_values, $entity)
 
 sanitizeKey ($key)
 
 tripalValuesTemplate ($field_definition, $default_value=NULL)
 
 getFieldMaxDelta ()
 

Static Public Member Functions

static defaultStorageSettings ()
 
static storageSettingsFormValidateBaseTable (array $form, FormStateInterface $form_state)
 
static storageSettingsFormValidateLinkingMethod (array $form, FormStateInterface $form_state)
 
static get_linker_table_and_column ($storage_settings, $default_table, $default_column)
 
static discoverPostprocess (array $field_list)
 
static getChadoTableDefs (array $table_names, ?ChadoSchema $schema=NULL)
 
static getChadoTableDef (string $table_name, ?ChadoSchema $schema=NULL)
 
static getChadoForeignKeyDef (string $left_table, ?string $right_table=NULL, ?ChadoSchema $schema=NULL)
 
- Static Public Member Functions inherited from Drupal\tripal\TripalField\TripalFieldItemBase
static defaultFieldSettings ()
 
static buildVocabularyTermTable (array &$elements, TripalTerm $term, TripalIdSpaceBase $idSpace, TripalVocabularyBase $vocabulary,)
 
static buildFieldTermForm ($field, $form, FormStateInterface $form_state)
 
static fieldSettingsFormValidate (array $form, FormStateInterface $form_state)
 
static propertyDefinitions (FieldStorageDefinitionInterface $field_definition)
 
static schema (FieldStorageDefinitionInterface $field_definition)
 
static getFormStateSettings (FormStateInterface $form_state)
 
static discover (TripalEntityType $bundle, string $field_id, array $field_types, array $field_instances)
 
static generateFieldName (TripalEntityType $bundle, string $extra, int $cvterm_id=0)
 
- Static Public Member Functions inherited from Drupal\tripal\TripalField\Interfaces\TripalFieldItemInterface
static tripalTypes ($field_definition)
 

Protected Member Functions

 getBaseTables ($linked_table, $has_linker_table=FALSE)
 
 getTableColumnSelectOptions ($table_name='', $column_types=[])
 
 getTableColumns ($table_name, $column_types=[])
 
 getLinkerTableSelectOptions ($object_table, $base_table, $delimiter=" \u{2192} ")
 
 getLinkerTables ($object_table, $base_table)
 
 removeIncompatibleField (string $bundle, string $machine_name)
 

Static Protected Member Functions

static parse_combined_table_and_column ($table_and_column)
 
static createFieldEntry (TripalEntityType $bundle, array $options)
 
static discoverBase (TripalEntityType $bundle, string $field_id, array $field_types, array $field_instances, array $options)
 
static discoverDirect (TripalEntityType $bundle, string $field_id, array $field_types, array $field_instances, array $options)
 
static discoverLinked (TripalEntityType $bundle, string $field_id, array $field_types, array $field_instances, array $options)
 
static getPossibleLinkingTables (array $options)
 
static getPrimaryKeys (array $table_names, ?ChadoSchema $schema=NULL)
 
static getPrimaryKey (string $table_name, ?ChadoSchema $schema=NULL)
 

Static Protected Attributes

static $record_id_term = 'SIO:000729'
 
static $select_base_column = FALSE
 
static $valid_base_column_types = []
 
static $object_table = NULL
 
static $table_column_delimiter = " \u{2192} "
 
static $drupal_entity_term = 'schema:ItemPage'
 
static $chadostorage_namespace = 'Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage'
 
static $drupal_entity_callback = 'drupalEntityIdLookupCallback'
 
static $mapping = NULL
 

Detailed Description

Defines the Tripal field item base class.

Member Function Documentation

◆ createFieldEntry()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::createFieldEntry ( TripalEntityType  $bundle,
array  $options 
)
staticprotected

Creates an array defining a single discovered field.

Parameters
TripalEntityType$bundleThe bundle that the field will be added to
array$optionsAll of the specific values for this field

◆ defaultStorageSettings()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::defaultStorageSettings ( )
static

{{}}

Reimplemented from Drupal\tripal\TripalField\TripalFieldItemBase.

Reimplemented in Drupal\tripal_chado\Plugin\Field\FieldType\ChadoAdditionalTypeTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoAnalysisTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoArrayDesignTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoAssayTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoBiomaterialTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoBooleanTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoContactByRoleTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoContactTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoDbxrefTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoFeatureMapTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoFeatureTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoIntegerTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoOrganismTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoProjectTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoPropertyTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoProtocolTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoRelationshipTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceChecksumTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceCoordinatesDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceLengthTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSourceDataTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStockTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStringTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStudyTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSynonymTypeDefault, and Drupal\tripal_chado\Plugin\Field\FieldType\ChadoTextTypeDefault.

◆ discoverBase()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::discoverBase ( TripalEntityType  $bundle,
string  $field_id,
array  $field_types,
array  $field_instances,
array  $options 
)
staticprotected

Discover fields that use a column in the base table.

This is used by ChadoFieldItemBase::discover().

Parameters
\Drupal\tripal\Entity\TripalEntityType$bundleThe entity type object for which new field instances should be found.
string$field_idThe id of the field.
array$field_typesAn array where each item defines a field type that is attached to this bundle. Each item is itself an array of the annotation defined at the top of that particular field type class.
array$field_instancesAn array of FieldConfig objects where each object defines a field attached to this content type.
array$optionsSpecific options from the field's discover() function. Required keys:
  • id: the field id, e.g. 'chado_organism_type_default'
  • name: the unique name for a specific field instance. The default is generated using generateFieldName().
  • base_table: the base table of the entity
  • base_column: the column containing the field's value
  • label: the field's label, e.g. 'Sequence'
  • termIdSpace: The field term's DB
  • termAccession: The field term's accession
  • description: A text description for the discovered field
Returns
array An associative array of fields to suggest that follows the same structure as expected by tripal.tripalfield_collection.* configuration.

◆ discoverDirect()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::discoverDirect ( TripalEntityType  $bundle,
string  $field_id,
array  $field_types,
array  $field_instances,
array  $options 
)
staticprotected

Discover fields that use a foreign key in the specified base table.

This is used by ChadoFieldItemBase::discover().

Parameters
\Drupal\tripal\Entity\TripalEntityType$bundleThe entity type object for which new field instances should be found.
string$field_idThe id of the field.
array$field_typesAn array where each item defines a field type that is attached to this bundle. Each item is itself an array of the annotation defined at the top of that particular field type class.
array$field_instancesAn array of FieldConfig objects where each object defines a field attached to this content type.
array$optionsSpecific options from the field's discover() function. Required keys:
  • id: the field id, e.g. 'chado_organism_type_default'
  • name: the unique name for a specific field instance. The default is generated using generateFieldName().
  • base_table: the base table of the entity
  • table: the field's table, e.g. 'organism'
  • label: the field's label, e.g. 'Organism'
  • termIdSpace: The field term's DB
  • termAccession: The field term's accession
  • description: A text description for the discovered field
Returns
array An associative array of fields to suggest that follows the same structure as expected by tripal.tripalfield_collection.* configuration.

◆ discoverLinked()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::discoverLinked ( TripalEntityType  $bundle,
string  $field_id,
array  $field_types,
array  $field_instances,
array  $options 
)
staticprotected

Discover fields that link to the base table through a linking table.

This is used by ChadoFieldItemBase::discover().

Parameters
\Drupal\tripal\Entity\TripalEntityType$bundleThe entity type object for which new field instances should be found.
string$field_idThe id of the field.
array$field_typesAn array where each item defines a field type that is attached to this bundle. Each item is itself an array of the annotation defined at the top of that particular field type class.
array$field_instancesAn array of FieldConfig objects where each object defines a field attached to this content type.
array$optionsSpecific options from the field's discover() function. Required keys:
  • id: the field id, e.g. 'chado_organism_type_default'
  • name: the unique name for a specific field instance. The default is generated using generateFieldName().
  • base_table: the base table of the entity
  • table: the field's table, e.g. 'organism'
  • label: the field's label, e.g. 'Organism'
  • termIdSpace: The field term's DB
  • termAccession: The field term's accession
  • description: A text description for the discovered field
  • custom_linker: either a string or an array of additional potential linker tables
Returns
array An associative array of fields to suggest that follows the same structure as expected by tripal.tripalfield_collection.* configuration.

◆ discoverPostprocess()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::discoverPostprocess ( array  $field_list)
static

Adds tripal term plugin IDs for the field's term.

Used for the field discovery process if a DB or CV is not a tripal collection yet.

Parameters
array$field_listDiscoverd field definitions.
Returns
array The same array with plugin IDs added.

◆ get_linker_table_and_column()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::get_linker_table_and_column (   $storage_settings,
  $default_table,
  $default_column 
)
static

Retrieve linker table and column from storage settings, used in a field's tripalTypes() function.

Parameters
array$storage_settingsStorage settings for a field
string$default_tableThis will be the base table for the field
string$default_columnThis will be the object pkey column for the field
Returns
array Returns linker_table and linker_fkey_column

◆ getBaseTables()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getBaseTables (   $linked_table,
  $has_linker_table = FALSE 
)
protected

Return a list of candidate base tables. We only want to present valid tables to the user, which are those with an appropriate foreign key.

Parameters
string$linked_tableThe Chado table being linked to via a foreign key.
bool$has_linker_tableWhen set to false (default), base tables are only those tables with a foreign key to $linked_table. When set to true, also include tables based on two foreign keys in linker tables, one to the specified $linked_table, and a second to a different table.
Returns
array The list of tables is returned in an alphabetized list ready to use in a form select.

◆ getChadoForeignKeyDef()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getChadoForeignKeyDef ( string  $left_table,
?string  $right_table = NULL,
?ChadoSchema  $schema = NULL 
)
static

Get a foreign key definition for a chado table.

Parameters
string$left_tableThe name of the table the foreign key resides in. E.g. 'feature' for the feature.type_id => cvterm.cvterm_id foreign key.
string | null$right_tableThe name of the table the foreign key refers to. For the example above it would be cvterm. If NULL, then all foreign keys are returned.
\tripal_chado\Database\ChadoSchema?Drupal,$schemaThe chado schema definition.
Returns
array The the foreign key definition, or an empty array if none exists.

◆ getChadoTableDef()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getChadoTableDef ( string  $table_name,
?ChadoSchema  $schema = NULL 
)
static

Get a single table definitions from the chado schema.

Parameters
string$table_nameThe table name to query.
Drupal\tripal_chado\Database\ChadoSchema | null$schemaThe chado schema definition.
Returns
array The table schema.

◆ getChadoTableDefs()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getChadoTableDefs ( array  $table_names,
?ChadoSchema  $schema = NULL 
)
static

Get multiple table definitions from the chado schema.

Parameters
array$table_namesThe table names to query.
Drupal\tripal_chado\Database\ChadoSchema | null$schemaThe chado schema definition.
Returns
array An associative array keyed by the table name, with value being the table schema.

◆ getLinkerTables()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getLinkerTables (   $object_table,
  $base_table 
)
protected

Return a list of candidate linking connections given a base table and a linked table. These can either be a column in the base table, or a connection through a linking table that connects the base table to the linked table.

Parameters
string$base_tableThe Chado table being used for the current entity (subject).
string$object_tableThe Chado table being linked to (object).
Returns
array The list of tables and columns.

◆ getLinkerTableSelectOptions()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getLinkerTableSelectOptions (   $object_table,
  $base_table,
  $delimiter = " \u{2192} " 
)
protected

Return a list of candidate linking connections given a base table and a linked table. These can either be a column in the base table, or a connection through a linking table that connects the base table to the linked table. In some cases there may be more than one way to link the two tables, so the list generated here can be presented to the site administrator to select the desired linking method.

Parameters
string$base_tableThe Chado table being used for the current entity (subject).
string$object_tableThe Chado table being linked to (object).
string$delimiterThe displayed delimiter between the table and column in the form select. This defaults to a right arrow.
Returns
array The list of tables is returned in an alphabetized list ready to use in a form select. The list elements will be in the format table.column

◆ getPossibleLinkingTables()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getPossibleLinkingTables ( array  $options)
staticprotected

Constructs a list of possible linking tables

Parameters
array$optionsThe options passed to discoverLinked(). Keys used here:
  • base_table: the base table of the entity
  • table: the field's table, e.g. 'organism'
  • custom_linker: either a string or an array of additional potential linker tables
Returns
array The list of tables to check

◆ getPrimaryKey()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getPrimaryKey ( string  $table_name,
?ChadoSchema  $schema = NULL 
)
staticprotected

Retrieves the name of the primary key for a Chado table.

To also support custom chado tables, the definition is loaded from the database if necessary. Note that this may return a different definition array, specifically the value may be an array instead of a string.

Parameters
string$table_nameThe chado table to look up the primary key for.
Drupal\tripal_chado\Database\ChadoSchema | null$schemaThe chado schema definition.
Returns
string|null The primary key name, or NULL if the table does not have a primary key.

◆ getPrimaryKeys()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getPrimaryKeys ( array  $table_names,
?ChadoSchema  $schema = NULL 
)
staticprotected

Retrieves the name of the primary key for Chado tables.

To also support custom chado tables, the definition is loaded from the database if necessary. Note that this may return a different definition array, specifically the value may be an array instead of a string.

Parameters
string$table_namesThe chado tables to look up the primary key for.
Drupal\tripal_chado\Database\ChadoSchema | null$schemaThe chado schema definition.
Returns
array An associative array keyed by the table name, with the value being the table primary key name or NULL if the table does not have a primary key.

◆ getTableColumns()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getTableColumns (   $table_name,
  $column_types = [] 
)
protected

Return a list of column names for the indicated table.

Parameters
string$table_nameThe Chado table of interest.
array$column_typesIf specified, limit to specified column types, e.g. "character varying", "text", "bigint", etc.
Returns
array The list of columns

◆ getTableColumnSelectOptions()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::getTableColumnSelectOptions (   $table_name = '',
  $column_types = [] 
)
protected

Return a list of column names for the indicated table.

Parameters
string$table_nameThe Chado table of interest.
array$column_typesIf specified, limit to specified column types, e.g. "character varying", "text", "bigint", etc.
Returns
array The list of columns is returned in an alphabetized list ready to use in a form select.

◆ isCompatible()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::isCompatible ( TripalEntityType  $entity_type)

Indicates if the field is compatible with the content type.

This function should be implemented by all Chado-based fields and indicate if the field is compatible with the specified content type. By default, it returns TRUE.

Parameters
TripalEntityType$entity_type
Returns
bool

Reimplemented in Drupal\tripal_chado\Plugin\Field\FieldType\ChadoAnalysisTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoArrayDesignTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoAssayTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoBiomaterialTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoBooleanTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoContactByRoleTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoContactTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoDbxrefTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoFeatureMapTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoFeatureTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoIntegerTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoOrganismTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoProjectTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoProtocolTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoRelationshipTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceChecksumTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceCoordinatesDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceLengthTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSequenceTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSourceDataTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStockTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStringTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoStudyTypeDefault, Drupal\tripal_chado\Plugin\Field\FieldType\ChadoSynonymTypeDefault, and Drupal\tripal_chado\Plugin\Field\FieldType\ChadoTextTypeDefault.

◆ parse_combined_table_and_column()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::parse_combined_table_and_column (   $table_and_column)
staticprotected

Parse a combined table + column string into its two parts

Parameters
string$table_and_columnTable and column delimited by self::table_column_delimiter, a right arrow by default, e.g."project → contact"
Returns
array Will contain 2 elements if valid, empty array if not.

◆ removeIncompatibleField()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::removeIncompatibleField ( string  $bundle,
string  $machine_name 
)
protected

Needed for Drupal ≤10.1 when an incompatible field was added to a content type, this will clean up the partially added field.

Parameters
string$bundleThe bundle name.
string$machine_nameThe field identifier, including the 'field_' prefix.

◆ storageSettingsFormBaseTableAjaxCallback()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::storageSettingsFormBaseTableAjaxCallback (   $form,
$form_state 
)

Ajax callback to update the base column select. The select can't be populated until we know the base table.

Parameters
array$formThe form array.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.

◆ storageSettingsFormLinkingMethodAjaxCallback()

Drupal\tripal_chado\TripalField\ChadoFieldItemBase::storageSettingsFormLinkingMethodAjaxCallback (   $form,
$form_state 
)

Ajax callback to update the linking method select. The select can't be populated until we know the base table.

Parameters
array$formThe form array.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.

◆ storageSettingsFormValidateBaseTable()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::storageSettingsFormValidateBaseTable ( array  $form,
FormStateInterface  $form_state 
)
static

Form element validation handler for base table

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.

◆ storageSettingsFormValidateLinkingMethod()

static Drupal\tripal_chado\TripalField\ChadoFieldItemBase::storageSettingsFormValidateLinkingMethod ( array  $form,
FormStateInterface  $form_state 
)
static

Form element validation handler for linking method (table + column)

Parameters
array$formThe form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.

The documentation for this class was generated from the following file: