rdf_sync-1.x-dev/rdf_sync.install
rdf_sync.install
<?php
/**
* @file
* Install, update, uninstall hook implementations for RDF Sync module.
*/
declare(strict_types=1);
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_schema().
*/
function rdf_sync_schema(): array {
return [
'rdf_sync_uri' => [
'description' => 'Stores relation between entities an their URI',
'fields' => [
'entity_type' => [
'type' => 'varchar_ascii',
'not null' => TRUE,
'length' => EntityTypeInterface::ID_MAX_LENGTH,
'description' => 'The entity type of the entity',
],
'entity_id' => [
'type' => 'varchar_ascii',
'not null' => TRUE,
'length' => 255,
'description' => 'The entity ID of the entity',
],
'uri' => [
'type' => 'varchar',
'not null' => TRUE,
// Limit to allow indexing.
// @see https://citnet.tech.ec.europa.eu/CITnet/jira/browse/ISAICP-7751
'length' => 768,
'description' => 'The RDF URI',
],
'bundle' => [
'type' => 'varchar',
'not null' => TRUE,
'length' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
'description' => 'Needed only for performance reasons',
],
],
'primary key' => ['entity_type', 'entity_id'],
'unique keys' => [
'uri' => ['uri'],
],
'indexes' => [
'bundle' => ['bundle'],
],
],
];
}
/**
* Implements hook_uninstall().
*/
function rdf_sync_uninstall($is_syncing): void {
\Drupal::state()->delete('rdf_sync.synchronization_disabled');
}
/**
* Convert configuration to a plugin system.
*/
function rdf_sync_update_8001(): void {
$config = \Drupal::configFactory()->getEditable('rdf_sync.settings');
$basic = $config->get('endpoint');
$basic = ['endpoint' => 'basic'] + $basic + [
'credentials' => ['user' => NULL, 'password' => NULL],
];
\Drupal::configFactory()->getEditable('rdf_sync.settings')
->set('connector', ['id' => 'virtuoso', 'config' => $basic])
->clear('endpoint')
->save(TRUE);
}
