Tripal
Loading...
Searching...
No Matches
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 ()
 
 getNonStoredTypes ()
 
 getStoredValues ()
 
 insertValues (&$values)
 
 updateValues (&$values)
 
 loadValues (&$values, bool $ignore_cached_fields=TRUE)
 
 deleteValues ($values)
 
 findValues ($values)
 
 validateValues ($values)
 
 markPropertiesForCaching (string $field_name, array &$prop_types)
 
 isDrupalStoreByFieldNameKey (string $field_name, string $key, object|null $property_type=NULL)
 
 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 its annotation 'id'.
object$field_definitionThe field configuration object. This can be an instance of: \Drupal\field\Entity\FieldStorageConfig or \Drupal\field\Entity\FieldConfig.
Returns
bool Returns true if no errors were encountered and false otherwise.

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

◆ 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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal\TripalStorage\TripalStorageBase.

◆ 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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ findValues()

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

Finds all property values for this backend instance based on $values.

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 An array of records that were found. Each record array is the same format as the $values argument but with all value objects set where values were found.

Implemented in 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 its annotation 'id'.
Returns
object 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.

◆ getNonStoredTypes()

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

Returns a list of property types that should not be stored in Drupal.

This is the inverse of the getStoredTypes() method. It's needed because all field property types have a column in the Drupal table. However, the "Stored" ones save the value both in Drupal and in the storage backend and the "unstored" ones save an empty value in Drupal that is populated on load by the storage backend.

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

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

◆ getPropertyType()

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

Returns a single propertyType object based on the parameters.

Parameters
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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ 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.

WARNING! 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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ isDrupalStoreByFieldNameKey()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::isDrupalStoreByFieldNameKey ( string  $field_name,
string  $key,
object|null  $property_type = NULL 
)

Check if a single field property should be cached in the Drupal tables.

This interacts with tripal_entity_type.default_cache_backend_field_values setting in the base implementation of this method.

WARNING: This method should only be called after the property type for this field.key combo has been added.

Parameters
string$field_nameThe name of the field thhe property to check is part of.
string$keyThe storage property key to check.
object | null$property_typeAn instance of the propertyType to be checked. Optional. If not provided it will be looked up by the field name and key.
Returns
bool|null TRUE if it should be saved to the Drupal field table and FALSE otherwise. If an error is encountered then NULL is returned.

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

◆ loadValues()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::loadValues ( $values,
bool  $ignore_cached_fields = TRUE 
)

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.
bool$ignore_cached_fieldsIf TRUE then values from fully cached fields should be ignored as they will be loaded by Drupal; if FALSE then load them from the tripal storage backend.
Returns
bool True if successful. False otherwise.

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

◆ markPropertiesForCaching()

Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::markPropertiesForCaching ( string  $field_name,
array &  $prop_types 
)

Marks which properties should be stored in the Drupal field tables.

Uses isDrupalStoreByFieldNameKey() to mark each property type as whether it should be cached in the Drupal tables or not. This should be done before calling TripalEntity::tripalClear() on these property types.

Parameters
string$field_nameThe name of the field that the following property types are part of.
array$prop_typesArray of \Drupal\tripal\TripalStorage\StoragePropertyType objects.

Implemented in Drupal\tripal\TripalStorage\TripalStorageBase.

◆ 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\TripalStorage\TripalStorageBase, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ 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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ 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\Plugin\TripalStorage\DrupalSqlStorage, and Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.


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