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

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, TripalLogger $logger)
 
- Public Member Functions inherited from Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface
 getStoredTypes ()
 
 getNonStoredTypes ()
 
 getStoredValues ()
 
 insertValues (&$values)
 
 updateValues (&$values)
 
 loadValues (&$values, bool $ignore_cached_fields=TRUE)
 
 deleteValues ($values)
 
 findValues ($values)
 
 validateValues ($values)
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 

Protected Attributes

 $logger
 
 $field_definitions = []
 
 $property_types = []
 
 $cached_fields = []
 
bool $default_is_required = TRUE
 
 addFieldDefinition (string $field_name, object $field_definition)
 
 getFieldDefinition (string $field_name)
 
 addTypes (string $field_name, array $types)
 
 getTypes ()
 
 getPropertyType (string $field_name, string $key)
 
 removeTypes (string $field_name, array $types)
 
 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)
 
 cloneValues ($values)
 
 resetValuesItem (&$values, $field_name, $delta)
 

Detailed Description

The base class for TripalStorage plugins.

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal\TripalStorage\TripalStorageBase::__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
TripalLogger  $logger 
)

Implements __construct().

Since we have implemented the ContainerFactoryPluginInterface, the constructor will be passed additional parameters added by the create() function. This allows our plugin to use dependency injection without our plugin manager service needing to worry about it.

Parameters
array$configurationThe configuration for the current plugin instance.
string$plugin_idThe unique ID for the current plugin instance.
mixed$plugin_definitionThe definition of the current plugin instance.
\Drupal\tripal\Services\TripalLogger$loggerAn instance of the Tripal logger to log messages to the admin.

Member Function Documentation

◆ addFieldDefinition()

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

Adds the field definition to our storage plugin instance for later use.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

Reimplemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ addTypes()

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

Adds property type objects for a specific field.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

Reimplemented in Drupal\tripal\Plugin\TripalStorage\DrupalSqlStorage.

◆ cloneValues()

Drupal\tripal\TripalStorage\TripalStorageBase::cloneValues (   $values)
protected

A helper function to clone a values array.

Parameters
array$valuesAn array of property values.

◆ create()

static Drupal\tripal\TripalStorage\TripalStorageBase::create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

Implements ContainerFactoryPluginInterface->create().

Since we have implemented the ContainerFactoryPluginInterface this static function will be called behind the scenes when a Plugin Manager uses createInstance(). Specifically this method is used to determine the parameters to pass to the constructor.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe container holding the services.
array$configurationConfiguration for the current plugin instance.
string$plugin_idThe unique ID of the current plugin instance.
mixed$plugin_definitionThe definition of the current plugin instance.
Returns
static

Reimplemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ getFieldDefinition()

Drupal\tripal\TripalStorage\TripalStorageBase::getFieldDefinition ( string  $field_name)

Gets a previously added field definition.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ getPropertyType()

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

Gets property type objects for a specific field.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ getTypes()

Drupal\tripal\TripalStorage\TripalStorageBase::getTypes ( )

Gets property type objects for all fields.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ isDrupalStoreByFieldNameKey()

Drupal\tripal\TripalStorage\TripalStorageBase::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.

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

Reimplemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ markPropertiesForCaching()

Drupal\tripal\TripalStorage\TripalStorageBase::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.

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ publishForm()

Drupal\tripal\TripalStorage\TripalStorageBase::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.

See also
\Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishForm()

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

Reimplemented in Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage.

◆ publishFormValidate()

Drupal\tripal\TripalStorage\TripalStorageBase::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.

See also
\Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishFormValidate()

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ publishFromSubmit()

Drupal\tripal\TripalStorage\TripalStorageBase::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.

See also
\Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishFromSubmit()

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ removeTypes()

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

Removes property types for a specific field.

inheritdoc}

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ resetValuesItem()

Drupal\tripal\TripalStorage\TripalStorageBase::resetValuesItem ( $values,
  $field_name,
  $delta 
)
protected

Sets the values for a field to be empty.

If the delta value doesn't exist in the values array then a new values array is added.

Parameters
array$valuesAn array of property values.
string$field_nameThe name of the field to addd an item to.
int$deltaThe index of the specific values item to reset.

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