Skip to content

Commit

Permalink
Merge pull request #162 from ConductionNL/fix/OP-450/directory-service
Browse files Browse the repository at this point in the history
Fix for adding Directory
  • Loading branch information
WilcoLouwerse authored Jan 10, 2025
2 parents 637d713 + c028dba commit 303b382
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/Service/DirectoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ServerException;
use JsonSerializable;
use OCA\OpenCatalogi\Db\Catalog;
use OCA\OpenCatalogi\Db\CatalogMapper;
use OCA\OpenCatalogi\Db\Listing;
use OCA\OpenCatalogi\Db\ListingMapper;
use OCA\OpenCatalogi\Service\BroadcastService;
use OCA\OpenCatalogi\Exception\DirectoryUrlException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IAppConfig;
Expand Down Expand Up @@ -105,7 +107,7 @@ private function getDirectoryFromListing(Listing|array $listing): array
if (isset($listing['publicationTypes']) && is_array($listing['publicationTypes'])) {
foreach ($listing['publicationTypes'] as &$publicationType) {
// Convert publicationType to array if it's an object
if ($publicationType instanceof \JsonSerializable) {
if ($publicationType instanceof JsonSerializable) {
$publicationType = $publicationType->jsonSerialize();
}

Expand Down Expand Up @@ -169,7 +171,7 @@ private function getDirectoryFromCatalog(Catalog|array $catalog): array
if (isset($catalog['publicationTypes']) && is_array($catalog['publicationTypes'])) {
foreach ($catalog['publicationTypes'] as &$publicationType) {
// Convert publicationType to array if it's an object
if ($publicationType instanceof \JsonSerializable) {
if ($publicationType instanceof JsonSerializable) {
$publicationType = $publicationType->jsonSerialize();
}
$publicationType['listed'] = true;
Expand Down Expand Up @@ -442,7 +444,11 @@ public function syncExternalDirectory(string $url): array

// Save the new listing
$listingObject = $this->objectService->saveObject('listing', $listing);
$listing = $listingObject->jsonSerialize();
if ($listing instanceof Entity) {
$listing = $listing->jsonSerialize();
} else {
$listing = $listingObject;
}
$foundDirectories[] = $listing['directory'];
$addedListings[] = $listing['directory'].'/'.$listing['id'];
}
Expand Down

0 comments on commit 303b382

Please sign in to comment.