Skip to content

Commit

Permalink
Merge pull request #127 from ConductionNL/development
Browse files Browse the repository at this point in the history
Bring fix to master for loading directory
  • Loading branch information
rjzondervan authored Oct 30, 2024
2 parents 03466b2 + 626205a commit 769a306
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/Service/DirectoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ private function getDirectoryFromListing(Listing|array $listing): array
// set listed and owner to false by default
$publicationType['listed'] = false;
$publicationType['owner'] = false;

// check if this publication type is used by this instance
if (isset($publicationType['source'])) {
// Get all external publication types used by this instance
$externalPublicationTypes = $this->getExternalPublicationTypes();

// Filter external types to find matches with the current publication type
$matchingTypes = array_filter($externalPublicationTypes, function($externalType) use ($publicationType) {
// Check if the external type has a source and if it matches the current publication type's source
return isset($externalType['source']) && $externalType['source'] === $publicationType['source'];
});

// Set 'listed' to true if there are any matching types, false otherwise
$publicationType['listed'] = !empty($matchingTypes);
}
Expand All @@ -192,8 +192,8 @@ private function getDirectoryFromCatalog(Catalog|array $catalog): array
// Set id to uuid if it's not a valid UUID and uuid field exists with a valid UUID
if (
(!isset($catalog['id']) && isset($catalog['uuid']))
||
(!Uuid::isValid($catalog['id']) && isset($catalog['uuid']) && Uuid::isValid($catalog['uuid']))
||
(!Uuid::isValid($catalog['id']) && isset($catalog['uuid']) && Uuid::isValid($catalog['uuid']))
) {
$catalog['id'] = $catalog['uuid'];
}
Expand Down Expand Up @@ -393,7 +393,8 @@ public function syncExternalDirectory(string $url): array
objectType: 'listing',
limit: 1,
filters: [
['id'=>$listing['id'], 'directory'=>$listing['directory']]
'id'=>$listing['id'],
'directory'=>$listing['directory']
]
);
if ($oldListing !== null && is_array($oldListing) && !empty($oldListing)) {
Expand Down Expand Up @@ -469,7 +470,7 @@ public function syncPublicationType(string $url): array
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Invalid JSON data received from the URL');
}

// Set the source to the URL
$publicationType['source'] = $url;

Expand Down

0 comments on commit 769a306

Please sign in to comment.