Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Commit

Permalink
Issue #17: Provide an update path.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed May 14, 2019
1 parent 47e76d2 commit 92191ef
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions rdf_entity.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Includes installation functions for the rdf_entity module.
*/

use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Serialization\Yaml;
use Drupal\sparql_entity_storage\Entity\SparqlGraph;
Expand Down Expand Up @@ -92,8 +93,22 @@ function rdf_entity_update_8003() {
* Split out the SPARQL entity storage.
*/
function rdf_entity_update_8004() {
// 1. Rename rdf_entity.graph.* > sparql_entity_storage.graph.*.
// 2. Rename third_party.rdf_entity > third_party.sparql_entity_storage in
// each field storage.
// 3. Rename rdf_entity.mapping.* > sparql_entity_storage.mapping.*.
$entity_type_manager = \Drupal::entityTypeManager();
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$config_factory = \Drupal::configFactory();

foreach (['mapping', 'graph'] as $type) {
// Install the new entity type definitions.
$entity_type = $entity_type_manager->getDefinition("sparql_$type");
$definition_update_manager->installEntityType($entity_type);

// Uninstall the old entity type definitions.
$entity_type = $definition_update_manager->getEntityType("rdf_entity_$type");
$definition_update_manager->uninstallEntityType($entity_type);

// Remove potential stale configuration objects.
foreach ($config_factory->listAll("rdf_entity.$type.") as $name) {
$config_factory->getEditable($name)->delete();
}
}
}

0 comments on commit 92191ef

Please sign in to comment.