-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1625 from tripal/tv4g1-1611-supportDrupalFields
Support drupal fields by adding a DrupalSQLStorage implementation
- Loading branch information
Showing
13 changed files
with
1,234 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Drupal\tripal\Plugin\TripalStorage; | ||
|
||
use Drupal\tripal\TripalStorage\TripalStorageBase; | ||
use Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\Validator\ConstraintViolation; | ||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\tripal\Services\TripalLogger; | ||
|
||
/** | ||
* Chado implementation of the TripalStorageInterface. | ||
* | ||
* @TripalStorage( | ||
* id = "drupal_sql_storage", | ||
* label = @Translation("Drupal SQL Storage"), | ||
* description = @Translation("This storage backend is used for fields which would like to use the default Drupal SQL-based field storage with a Tripal-based Field."), | ||
* ) | ||
*/ | ||
class DrupalSqlStorage extends TripalStorageBase implements TripalStorageInterface { | ||
|
||
/** | ||
* @{inheritdoc} | ||
* | ||
* OVERRIDES TripalStorageBase to ensure all field properties are set | ||
* to save to Drupal! | ||
*/ | ||
public function addTypes(string $field_name, array $types) { | ||
|
||
// Esnure all properties of a field using Drupal storage is | ||
// set to store it's values in the Drupal database. | ||
foreach ($types as $type) { | ||
$storage_settings = $type->getStorageSettings(); | ||
$storage_settings['drupal_store'] = TRUE; | ||
$type->setStorageSettings($storage_settings); | ||
} | ||
|
||
// Now let TripalStorageBase deal with these improved property types. | ||
parent::addTypes($field_name, $types); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function updateValues(&$values): bool { | ||
// No need to do anything here. This is handled by the | ||
// default SQL storage provided by Drupal | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function deleteValues($values): bool { | ||
// No need to do anything here. This is handled by the | ||
// default SQL storage provided by Drupal | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function findValues($values) { | ||
/** @todo: impelment this function properly **/ | ||
return $values; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function insertValues(&$values): bool { | ||
// No need to do anything here. This is handled by the | ||
// default SQL storage provided by Drupal | ||
return TRUE; | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function loadValues(&$values): bool { | ||
// No need to do anything here. This is handled by the | ||
// default SQL storage provided by Drupal | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function validateValues($values) { | ||
// No need to do anything here. This is handled by the | ||
// default SQL storage provided by Drupal | ||
$violations = []; | ||
return $violations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.