Tripal
Public Member Functions | List of all members
Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface Interface Reference
Inheritance diagram for Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface:
Collaboration graph
[legend]

Public Member Functions

 addTypes (string $field_name, array $types)
 
 removeTypes (string $field_name, array $types)
 
 getTypes ()
 
 getPropertyType (string $field_name, string $key)
 
 addFieldDefinition (string $field_name, object $field_definition)
 
 getFieldDefinition (string $field_name)
 
 getStoredTypes ()
 
 getStoredValues ()
 
 insertValues (&$values)
 
 updateValues (&$values)
 
 loadValues (&$values)
 
 deleteValues ($values)
 
 findValues ($values)
 
 validateValues ($values)
 
 publishForm ($form, FormStateInterface &$form_state)
 
 publishFormValidate ($form, FormStateInterface &$form_state)
 
 publishFromSubmit ($form, FormStateInterface &$form_state)
 

Detailed Description

Defines an interface for tripal storage plugins.

Member Function Documentation

◆ addFieldDefinition()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::addFieldDefinition ( string  $field_name,
object  $field_definition 
)

Stores the field definition for a given field.

NOTE: the definition for every field mentioned in the values array of an insert/update/load/find/deleteValues() method must be added using this function before the *Values() method can be called.

Parameters
string$field_nameThe name of the field based on it's annotation 'id'.
object$field_definitionThe field configuration object. This can be an instance of: \Drupal\field\Entity\FieldStorageConfig or \Drupal\field\Entity\FieldConfig
Returns
boolean Returns true if no errors were encountered and false otherwise.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\TripalStorage\TripalStorageBase.

◆ addTypes()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::addTypes ( string  $field_name,
array  $types 
)

Adds the given array of new property types to this tripal storage plugin.

Parameters
string$field_nameThe name of the field the properties belong to.
array$typesArray of \Drupal\tripal\TripalStorage\StoragePropertyTypeBase objects.

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ deleteValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::deleteValues (   $values)

Deletes the given array of property values from this tripal storage plugin.

Parameters
array$valuesArray of \Drupal\tripal\TripalStorage\StoragePropertyValue objects.
Returns
bool True if successful. False otherwise.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ findValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::findValues (   $values)

Finds and returns all property values stored in this storage plugin implementation that matches the given match argument.

Parameters
array$valuesAssociative array 5-levels deep. The 1st level is the field name (e.g. ChadoOrganismDefault). The 2nd level is the delta value (e.g. 0). The 3rd level is a field key name (i.e. record_id + value). The 4th level must contain the following three keys/value pairs
  • "value": a \Drupal\tripal\TripalStorage\StoragePropertyValue object
  • "type": a\Drupal\tripal\TripalStorage\StoragePropertyType object
  • "definition": a \Drupal\Field\Entity\FieldConfig object When the function returns, any values retrieved from the data store will be set in the StoragePropertyValue object.
Returns
array
Todo:
fix this return value... Array of all \Drupal\tripal\TripalStorage\StoragePropertyValue objects that match.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ getFieldDefinition()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getFieldDefinition ( string  $field_name)

Retrieves the stored field definition of a given field.

Parameters
string$field_nameThe name of the field based on it's annotation 'id'.
Returns
object $field_definition The field configuration object. This can be an instance of: \Drupal\field\Entity\FieldStorageConfig or \Drupal\field\Entity\FieldConfig

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ getPropertyType()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getPropertyType ( string  $field_name,
string  $key 
)

Returns a single propertyType object based on the parameters.

Parameters
string$bundle_nameThe name of the bundle on which the field is attached that the properties belong to.
string$field_nameThe name of the field the properties belong to.
string$keyThe key of the property type to return.
Returns
object An instance of the propertyType indicated.

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ getStoredTypes()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getStoredTypes ( )

Returns a list of property types that should be stored.

In order to link data in the storage backend, the storage system must link the record in someway with Drupal entities. This most likely happens in tables in the Drupal schema (usually the public schema). This function should return the list of properties that must be stored in order to uniquely identify an entity in the datastore.

Returns
@array Array of \Drupal\tripal\Base\StoragePropertyTypeBase objects.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ getStoredValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getStoredValues ( )

Returns a list of property values for stored types..

This function returns an array of property value objects that correspond to the types returned by getStoredTypes().

Returns
@array Array of \Drupal\tripal\TripalStorage\StoragePropertyValue objects.

◆ getTypes()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getTypes ( )

Returns a list of all property types added to this storage plugin type. WARING! This could be a very expensive call!

Returns
array Array of all \Drupal\tripal\Base\StoragePropertyTypeBase objects that have been added to this storage plugin type.

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ insertValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::insertValues ( $values)

Inserts values in the field data store.

The record Ids of the inserted records will be set in the property value objects.

Parameters
array$valuesAssociative array 5-levels deep. The 1st level is the field name (e.g. ChadoOrganismDefault). The 2nd level is the delta value (e.g. 0). The 3rd level is a field key name (i.e. record_id + value). The 4th level must contain the following three keys/value pairs
  • "value": a \Drupal\tripal\TripalStorage\StoragePropertyValue object
  • "type": a\Drupal\tripal\TripalStorage\StoragePropertyType object
  • "definition": a \Drupal\Field\Entity\FieldConfig object When the function returns, any values retrieved from the data store will be set in the StoragePropertyValue object.
Returns
bool True if successful. False otherwise.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ loadValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::loadValues ( $values)

Loads the values of the field data store.

Parameters
array$valuesAssociative array 5-levels deep. The 1st level is the field name (e.g. ChadoOrganismDefault). The 2nd level is the delta value (e.g. 0). The 3rd level is a field key name (i.e. record_id + value). The 4th level must contain the following three keys/value pairs
  • "value": a \Drupal\tripal\TripalStorage\StoragePropertyValue object
  • "type": a\Drupal\tripal\TripalStorage\StoragePropertyType object
  • "definition": a \Drupal\Field\Entity\FieldConfig object
Returns
bool True if successful. False otherwise.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ publishForm()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishForm (   $form,
FormStateInterface &  $form_state 
)

Provides form elements to be added to the Tripal entity publish form.

Parameters
array$formThe form array definition.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.
Returns
array A new form array definition containing the form elements to add to the publish form.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\TripalStorage\TripalStorageBase.

◆ publishFormValidate()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishFormValidate (   $form,
FormStateInterface &  $form_state 
)

Handles validation of the publish form elements.

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

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ publishFromSubmit()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishFromSubmit (   $form,
FormStateInterface &  $form_state 
)

Handles submission of the form elements for the storage backend.

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

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ removeTypes()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::removeTypes ( string  $field_name,
array  $types 
)

Removes the given array of property types from this tripal storage plugin.

Parameters
string$field_nameThe name of the field the properties belong to.
array$typesArray of \Drupal\tripal\TripalStorage\StoragePropertyTypeBase objects.

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ updateValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::updateValues ( $values)

Updates values in the field data store.

Parameters
array$valuesAssociative array 5-levels deep. The 1st level is the field name (e.g. ChadoOrganismDefault). The 2nd level is the delta value (e.g. 0). The 3rd level is a field key name (i.e. record_id + value). The 4th level must contain the following three keys/value pairs
  • "value": a \Drupal\tripal\TripalStorage\StoragePropertyValue object
  • "type": a\Drupal\tripal\TripalStorage\StoragePropertyType object
  • "definition": a \Drupal\Field\Entity\FieldConfig object When the function returns, any values retrieved from the data store will be set in the StoragePropertyValue object.
Returns
bool True if successful. False otherwise.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ validateValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::validateValues (   $values)

Performs validation checks on values.

Parameters
array$valuesArray of \Drupal\tripal\TripalStorage\StoragePropertyValue objects.
Returns
array An array of \Symfony\Component\Validator\ConstraintViolation objects.

Implemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage, and Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.


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