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

Public Member Functions

 handleAutocomplete (Request $request, int $match_limit=5)
 
- Public Member Functions inherited from Drupal\tripal_chado\Controller\ChadoGenericAutocompleteController
 handleGenericAutocomplete (Request $request, string $base_table, string $column_name, string $type_column, string $property_table, int $match_limit=10, int $type_id=0,)
 

Static Public Member Functions

static getQuery (string $string, array $options)
 
static getPkeyId (?string $value=NULL)
 
static getFormElement (array $element, mixed $default, array $options=[])
 
static getSelectElement (array $element, mixed $default, array $options=[])
 
static getAutocompleteElement (array $element, mixed $default, array $options=[])
 
static getSelectOptions (array $options)
 
static validateAutocomplete ($element, FormStateInterface $form_state)
 
- Static Public Member Functions inherited from Drupal\tripal_chado\Controller\ChadoGenericAutocompleteController
static getDefaultOptions ()
 
static getPkeyId (string $value)
 

Additional Inherited Members

- Protected Attributes inherited from Drupal\tripal_chado\Controller\ChadoGenericAutocompleteController
bool $include_pkey = TRUE
 
string $match_operator = 'CONTAINS'
 
- Static Protected Attributes inherited from Drupal\tripal_chado\Controller\ChadoGenericAutocompleteController
static array $default_options = []
 

Detailed Description

Controller, Chado Organism Autocomplete.

Member Function Documentation

◆ getAutocompleteElement()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getAutocompleteElement ( array  $element,
mixed  $default,
array  $options = [] 
)
static

Provides a textfield form element that autocompletes with chado organisms.

Parameters
array$elementThe form element array to be populated.
mixed$defaultThe default value, either an integer pkey ID or a string.
array$optionsselect_limit - The maximum number of options to show in a select list. match_operator - Either 'CONTAINS' (default) or 'STARTS_WITH'. match_limit - Desired number of autocomplete matching names to suggest. size - The size of the textfield for autocomplete. placeholder - Placeholder text for the autocomplete textfield.
Returns
array|null A form element array, an autocomplete.

◆ getFormElement()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getFormElement ( array  $element,
mixed  $default,
array  $options = [] 
)
static

Returns a form element array, either a select or an autocomplete.

Parameters
array$elementThe form element array to be populated.
mixed$defaultThe default value, either an integer pkey ID or a string.
array$optionsThe following keys are used:
  • select_limit: The maximum number of options to show in a select list before switching to an autocomplete instead. A value of zero means always use an autocomplete.
  • match_operator: Either 'CONTAINS' (default) or 'STARTS_WITH'.
  • match_limit: Desired number of autocomplete matching names to suggest.
  • size: The size of the textfield for autocomplete.
  • placeholder: Placeholder text for the autocomplete textfield.
Returns
array|null A form element array, either a select or an autocomplete.

◆ getPkeyId()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getPkeyId ( ?string  $value = NULL)
static

Fetch the pkey organism_id number, given an autocomplete value.

The value includes a numeric ID in parentheses at the end of the string.

Parameters
?string$value A value from an autocomplete with the ID in parentheses at the end, e.g. "Tripalus bogusii (ignored) (123)".
Returns
int Primary key ID number of the record, or 0 if an unparsable $value was passed, which can happen if the user did not let the autocomplete supply a value.

◆ getQuery()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getQuery ( string  $string,
array  $options 
)
static

Returns a database query ready to execute.

This allows the same query to be used for both autocomplete and select.

Parameters
string$stringThe string to be autocompleted, used to limit the query. The string "%" has the special meaning of return all records.
array$optionsThe following keys are used: match_operator - Either 'CONTAINS' (default) or 'STARTS_WITH'. match_limit - Desired number of autocomplete matching names to suggest.
Returns
?\Drupal\pgsql\Driver\Database\pgsql\Select A database query object

Reimplemented from Drupal\tripal_chado\Controller\ChadoGenericAutocompleteController.

◆ getSelectElement()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getSelectElement ( array  $element,
mixed  $default,
array  $options = [] 
)
static

Provides a Drupal form element with a select list of Chado organisms.

Parameters
array$elementThe form element array to be populated.
mixed$defaultThe default value, either an integer pkey ID or a string.
array$optionsselect_limit - The maximum number of options to show in a select list. match_operator - Either 'CONTAINS' (default) or 'STARTS_WITH'. match_limit - Desired number of matching names to suggest.
Returns
array|null A form element array, either a select element.

◆ getSelectOptions()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::getSelectOptions ( array  $options)
static

Provides an organism list for use as select options.

Parameters
array$optionsselect_limit - The maximum number of options to show in a select list. match_limit - Desired number of matching names to suggest.
Returns
array An associative array where the key is the organism_id and the value is either the abbreviation or the scientific name. More specifically, if the abbreviation is present then that will be used and if not, the scientific name will be resolved using the genus, species and infraspecific columns.

◆ handleAutocomplete()

Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::handleAutocomplete ( Request  $request,
int  $match_limit = 5 
)

Controller method, autocomplete organism name.

Parameters
Symfony\Component\HttpFoundation\Request$requestThe request object.
int$match_limitDesired number of matching organism names to suggest. Default to 5 items. Must be declared in autocomplete route parameter.
Returns
JsonObject Matching organism rows in an array where organism name is both the value to the array keys label and value.

◆ validateAutocomplete()

static Drupal\tripal_chado\Controller\ChadoOrganismFormElementController::validateAutocomplete (   $element,
FormStateInterface  $form_state 
)
static

Form element validation handler for an autocomplete field.

Parameters
array$elementThe form element being validated.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state of the (entire) configuration form.

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