diff --git a/.babelrc b/.babelrc old mode 100755 new mode 100644 diff --git a/.eslintrc.js b/.eslintrc.js old mode 100755 new mode 100644 diff --git a/.gitattributes b/.gitattributes old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/.nvmrc b/.nvmrc old mode 100755 new mode 100644 diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php old mode 100755 new mode 100644 diff --git a/.prettierrc b/.prettierrc old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/appinfo/info.xml b/appinfo/info.xml old mode 100755 new mode 100644 index b11b60225c..d013b1f08f --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,7 +22,7 @@ Create a [bug report](https://github.com/OpenRegister/.github/issues/new/choose) Create a [feature request](https://github.com/OpenRegister/.github/issues/new/choose) ]]> - 0.1.22 + 0.1.33 agpl Conduction OpenRegister diff --git a/appinfo/routes.php b/appinfo/routes.php old mode 100755 new mode 100644 diff --git a/composer-setup.php b/composer-setup.php old mode 100755 new mode 100644 diff --git a/composer.json b/composer.json old mode 100755 new mode 100644 diff --git a/composer.lock b/composer.lock old mode 100755 new mode 100644 diff --git a/css/main.css b/css/main.css old mode 100755 new mode 100644 diff --git a/docs/styleguide.md b/docs/styleguide.md old mode 100755 new mode 100644 diff --git a/img/app-dark.svg b/img/app-dark.svg old mode 100755 new mode 100644 diff --git a/img/app.svg b/img/app.svg old mode 100755 new mode 100644 diff --git a/jest.config.js b/jest.config.js old mode 100755 new mode 100644 diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php old mode 100755 new mode 100644 diff --git a/lib/Controller/DashboardController.php b/lib/Controller/DashboardController.php old mode 100755 new mode 100644 diff --git a/lib/Migration/Version1Date20240924200009.php b/lib/Migration/Version1Date20240924200009.php old mode 100755 new mode 100644 diff --git a/lib/Migration/Version1Date20241019205009.php b/lib/Migration/Version1Date20241019205009.php old mode 100755 new mode 100644 diff --git a/lib/Migration/Version1Date20241020231700.php b/lib/Migration/Version1Date20241020231700.php old mode 100755 new mode 100644 diff --git a/lib/Migration/Version1Date20241022135300.php b/lib/Migration/Version1Date20241022135300.php old mode 100755 new mode 100644 diff --git a/lib/Service/MongoDbService.php b/lib/Service/MongoDbService.php old mode 100755 new mode 100644 diff --git a/lib/Service/ObjectService.php b/lib/Service/ObjectService.php old mode 100755 new mode 100644 index 0ec366366a..39d64fe0a4 --- a/lib/Service/ObjectService.php +++ b/lib/Service/ObjectService.php @@ -202,28 +202,39 @@ public function find(int|string $id, ?array $extend = []): ?ObjectEntity * @throws ValidationException If validation fails. * @throws GuzzleException If there is an error during file upload. */ - public function createFromArray(array $object): ObjectEntity + public function createFromArray(array $object, ?array $extend = []): array { - return $this->saveObject( - register: $this->getRegister(), - schema: $this->getSchema(), - object: $object - ); - } + $objectEntity = $this->saveObject( + register: $this->getRegister(), + schema: $this->getSchema(), + object: $object + ); + + // Lets turn the whole thing into an array + $objectEntity = $objectEntity->jsonSerialize(); + + // Extend object with properties if requested + if (empty($extend) === false) { + $objectEntity = $this->extendEntity(entity: $objectEntity, extend: $extend); + } + + return $objectEntity; + } /** * Updates an existing object with new data. * - * @param string $id The ID of the object to update. - * @param array $object The new data for the object. - * @param bool $updatedObject If true, performs a full update. If false, performs a patch update. - * @param bool $patch Determines if the update should merge with existing data. + * @param string $id The object ID to update + * @param array $object The new object data + * @param bool $updateVersion Whether this is an update operation + * @param bool $patch Whether this is a patch operation + * @param array|null $extend Properties to extend with related data * * @return ObjectEntity The updated object entity. * @throws ValidationException If validation fails. * @throws GuzzleException If there is an error during file upload. */ - public function updateFromArray(string $id, array $object, bool $updatedObject, bool $patch = false): ObjectEntity + public function updateFromArray(string $id, array $object, bool $updateVersion, bool $patch = false, ?array $extend = []): array { $object['id'] = $id; @@ -237,12 +248,22 @@ public function updateFromArray(string $id, array $object, bool $updatedObject, $object = array_merge($oldObject, $object); } - return $this->saveObject( - register: $this->getRegister(), - schema: $this->getSchema(), - object: $object - ); - } + $objectEntity = $this->saveObject( + register: $this->getRegister(), + schema: $this->getSchema(), + object: $object, + ); + + // Lets turn the whole thing into an array + $objectEntity = $objectEntity->jsonSerialize(); + + // Extend object with properties if requested + if (empty($extend) === false) { + $objectEntity = $this->extendEntity(entity: $objectEntity, extend: $extend); + } + + return $objectEntity; + } /** * Deletes an object. @@ -1567,30 +1588,37 @@ public function extendEntity(array $entity, array $extend): array } /** - * Retrieves all registers with their associated schema data. + * Get all registers extended with their schemas * - * Converts registers to arrays and extends them with schema information as needed. - * - * @return array The list of registers with extended schema details. - * @throws Exception If extending schemas fails. + * @return array The registers with schema data + * @throws Exception If extension fails */ public function getRegisters(): array { // Get all registers $registers = $this->registerMapper->findAll(); - // Convert to arrays - $registers = array_map(function ($object) { - return $object->jsonSerialize(); - }, $registers); + // Convert to arrays and extend schemas + $registers = array_map(function($register) { + $registerArray = is_array($register) ? $register : $register->jsonSerialize(); + + // Replace schema IDs with actual schema objects if schemas property exists + if (isset($registerArray['schemas']) && is_array($registerArray['schemas'])) { + $registerArray['schemas'] = array_map( + function($schemaId) { + try { + return $this->schemaMapper->find($schemaId)->jsonSerialize(); + } catch (Exception $e) { + // If schema can't be found, return the ID + return $schemaId; + } + }, + $registerArray['schemas'] + ); + } - // Extend with schemas - $extend = ['schemas']; - if (empty($extend) === false) { - $registers = array_map(function ($object) use ($extend) { - return $this->extendEntity(entity: $object, extend: $extend); - }, $registers); - } + return $registerArray; + }, $registers); return $registers; } diff --git a/lib/Service/ValidationService.php b/lib/Service/ValidationService.php old mode 100755 new mode 100644 diff --git a/openapi.json b/openapi.json old mode 100755 new mode 100644 diff --git a/package-lock.json b/package-lock.json old mode 100755 new mode 100644 diff --git a/package.json b/package.json old mode 100755 new mode 100644 diff --git a/phpmd.xml b/phpmd.xml old mode 100755 new mode 100644 diff --git a/phpunit.xml b/phpunit.xml old mode 100755 new mode 100644 diff --git a/psalm copy.xml b/psalm copy.xml old mode 100755 new mode 100644 diff --git a/psalm.xml b/psalm.xml old mode 100755 new mode 100644 diff --git a/src/App.vue b/src/App.vue old mode 100755 new mode 100644 diff --git a/src/dialogs/Dialogs.vue b/src/dialogs/Dialogs.vue old mode 100755 new mode 100644 diff --git a/src/entities/index.js b/src/entities/index.js old mode 100755 new mode 100644 diff --git a/src/entities/register/index.js b/src/entities/register/index.js old mode 100755 new mode 100644 diff --git a/src/entities/schema/index.js b/src/entities/schema/index.js old mode 100755 new mode 100644 diff --git a/src/entities/source/index.js b/src/entities/source/index.js old mode 100755 new mode 100644 diff --git a/src/main.js b/src/main.js old mode 100755 new mode 100644 diff --git a/src/modals/Modals.vue b/src/modals/Modals.vue old mode 100755 new mode 100644 diff --git a/src/navigation/Configuration.vue b/src/navigation/Configuration.vue old mode 100755 new mode 100644 diff --git a/src/navigation/MainMenu.vue b/src/navigation/MainMenu.vue old mode 100755 new mode 100644 diff --git a/src/pinia.js b/src/pinia.js old mode 100755 new mode 100644 diff --git a/src/sidebars/SideBars.vue b/src/sidebars/SideBars.vue old mode 100755 new mode 100644 diff --git a/src/sidebars/dashboard/DashboardSideBar.vue b/src/sidebars/dashboard/DashboardSideBar.vue old mode 100755 new mode 100644 diff --git a/src/sidebars/search/SearchSideBar.vue b/src/sidebars/search/SearchSideBar.vue old mode 100755 new mode 100644 diff --git a/src/store/modules/navigation.js b/src/store/modules/navigation.js old mode 100755 new mode 100644 diff --git a/src/store/modules/navigation.spec.js b/src/store/modules/navigation.spec.js old mode 100755 new mode 100644 diff --git a/src/store/store.js b/src/store/store.js old mode 100755 new mode 100644 diff --git a/src/views/Views.vue b/src/views/Views.vue old mode 100755 new mode 100644 diff --git a/src/views/dashboard/DashboardIndex.vue b/src/views/dashboard/DashboardIndex.vue old mode 100755 new mode 100644 diff --git a/stylelint.config.js b/stylelint.config.js old mode 100755 new mode 100644 diff --git a/templates/index.php b/templates/index.php old mode 100755 new mode 100644 diff --git a/tsconfig.json b/tsconfig.json old mode 100755 new mode 100644 diff --git a/webpack.config.js b/webpack.config.js old mode 100755 new mode 100644