diff --git a/lib/Service/AangebodenGebruikService.php b/lib/Service/AangebodenGebruikService.php index b08f04cd9..6b5cc854a 100644 --- a/lib/Service/AangebodenGebruikService.php +++ b/lib/Service/AangebodenGebruikService.php @@ -1223,166 +1223,6 @@ private function resolveVoorzieningenSchemaConfig(string $schemaKey, string $lab throw new Exception(ucfirst($labelForLogs) . ' configuration not found. Please configure the schemas in the admin panel.'); }//end resolveVoorzieningenSchemaConfig() - /** - * Get all applications/modules owned by an organization - * - * @param ObjectServiceInterface $objectService The OpenRegister object service - * @param string $organisationUuid The organization UUID - * - * @return array Array of application/module UUIDs - * - * @throws Exception When query fails - */ - private function getApplicationsOwnedByOrganisation( - ObjectServiceInterface $objectService, - string $organisationUuid, - ): array { - try { - $voorzieningenConfig = $this->settingsService->getVoorzieningenConfig(); - $registerId = $voorzieningenConfig['register'] ?? null; - - if ($registerId === null) { - return []; - } - - $appUuids = []; - - // Check suite schema (applications). - if (isset($voorzieningenConfig['suite_schema']) === true) { - $suiteQuery = [ - '@self' => [ - 'register' => $registerId, - 'schema' => $voorzieningenConfig['suite_schema'], - 'organisation' => $organisationUuid, - ], - '_source' => 'database', - '_limit' => 500, - ]; - - $suites = $objectService->searchObjects( - query: $suiteQuery, - _rbac: false, - _multitenancy: false - ); - - foreach ($suites as $suite) { - $suiteData = $suite; - if (is_array(value: $suite) === false) { - $suiteData = $suite->getObject(); - } - - $appUuids[] = $suiteData['uuid'] ?? $suiteData['id'] ?? null; - } - }//end if - - // Check module schema. - if (isset($voorzieningenConfig['module_schema']) === true) { - $moduleQuery = [ - '@self' => [ - 'register' => $registerId, - 'schema' => $voorzieningenConfig['module_schema'], - 'organisation' => $organisationUuid, - ], - '_source' => 'database', - '_limit' => 500, - ]; - - $modules = $objectService->searchObjects( - query: $moduleQuery, - _rbac: false, - _multitenancy: false - ); - - foreach ($modules as $module) { - $moduleData = $module; - if (is_array(value: $module) === false) { - $moduleData = $module->getObject(); - } - - $appUuids[] = $moduleData['uuid'] ?? $moduleData['id'] ?? null; - } - }//end if - - // Filter out nulls. - $appUuids = array_filter($appUuids); - - $this->logger->debug( - 'Found applications owned by organization', - [ - 'organisation' => $organisationUuid, - 'count' => count($appUuids), - ] - ); - - return $appUuids; - } catch (Exception $e) { - $this->logger->error( - 'Failed to get applications owned by organization', - [ - 'organisation' => $organisationUuid, - 'error' => $e->getMessage(), - ] - ); - return []; - }//end try - }//end getApplicationsOwnedByOrganisation() - - /** - * Check if an organization owns a specific application/module - * - * @param ObjectServiceInterface $objectService The OpenRegister object service - * @param string $appUuid The application/module UUID - * @param string $organisationUuid The organization UUID - * - * @return bool True if organization owns the application/module - */ - private function checkOrganisationOwnership( - ObjectServiceInterface $objectService, - string $appUuid, - string $organisationUuid, - ): bool { - try { - // Get the application/module object. - $appObject = $objectService->find( - id: $appUuid, - _rbac: false, - _multitenancy: false - ); - - if ($appObject === null) { - return false; - } - - // Check if the organization owns it. - $appData = $appObject->getObject(); - $ownerOrg = $appData['@self']['organisation'] ?? null; - - $isOwner = ($ownerOrg === $organisationUuid); - - $this->logger->debug( - 'Checked organization ownership', - [ - 'app_uuid' => $appUuid, - 'organisation' => $organisationUuid, - 'owner_org' => $ownerOrg, - 'is_owner' => $isOwner, - ] - ); - - return $isOwner; - } catch (Exception $e) { - $this->logger->error( - 'Failed to check organization ownership', - [ - 'app_uuid' => $appUuid, - 'organisation' => $organisationUuid, - 'error' => $e->getMessage(), - ] - ); - return false; - }//end try - }//end checkOrganisationOwnership() - /** * Mapping from organisatie.type to registeredBy value */ diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8e1cabaf0..eb8499ab5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -75,16 +75,6 @@ parameters: count: 1 path: lib/Service/AangebodenGebruikService.php - - - message: "#^Method OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:checkOrganisationOwnership\\(\\) is unused\\.$#" - count: 1 - path: lib/Service/AangebodenGebruikService.php - - - - message: "#^Method OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:getApplicationsOwnedByOrganisation\\(\\) is unused\\.$#" - count: 1 - path: lib/Service/AangebodenGebruikService.php - - message: "#^Property OCA\\\\Stackiq\\\\Service\\\\AangebodenGebruikService\\:\\:\\$config is never read, only written\\.$#" count: 1