Add 'dangerously_use_adapter_prefixes' setting

This commit adds a setting to not scan the triplestore for prefixes, but
instead use the prefixes listed in adapaters as the only URIs to
resolve.
This commit is contained in:
Tom Wiesing 2024-04-08 14:43:40 +02:00
parent fd53a901c3
commit 7763644ebe
No known key found for this signature in database
4 changed files with 69 additions and 14 deletions

View file

@ -1,16 +1,16 @@
<?php
/**
* list_prefixes lists all content prefixes known to this WissKI.
* list_triplestore_prefixes returns the prefixes of all objects found in the triplestore.
* Prefixes are not filtered, and may contain duplicates.
*/
function list_prefixes() {
function list_triplestore_prefixes() {
$prefixes = [];
$storage = \Drupal::entityTypeManager()->getStorage('wisski_salz_adapter');
foreach ($storage->loadMultiple() as $adapter) {
// load all the prefixes from the triplestore
$engine = $adapter->getEngine();
getTriplestorePrefixes($adapter->getEngine(), $prefixes);
get_prefixes_from_engine($adapter->getEngine(), $prefixes);
// read the configuration to check if we have a default graph
$conf = $engine->getConfiguration();
@ -22,7 +22,29 @@ function list_prefixes() {
return $prefixes;
}
function getTriplestorePrefixes($engine, &$prefixes) {
/**
* list_adapter_prefixes returns the prefixes of all adapters.
* Prefixes are not filtered, and may contain duplicates.
*/
function list_adapter_prefixes() {
$prefixes = [];
$storage = \Drupal::entityTypeManager()->getStorage('wisski_salz_adapter');
foreach ($storage->loadMultiple() as $adapter) {
// load all the prefixes from the triplestore
$engine = $adapter->getEngine();
// read the configuration to check if we have a default graph
$conf = $engine->getConfiguration();
if(!array_key_exists('default_graph', $conf)) {
continue;
}
$prefixes[] = $conf['default_graph'];
}
return $prefixes;
}
function get_prefixes_from_engine($engine, &$prefixes) {
// some adapters don't support a query method!
if (!method_exists($engine, 'directQuery')) return NULL;