From 0057a1b1d82b52535b24db92819e0f91cb64c255 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 2 Nov 2026 19:05:19 +0100 Subject: [PATCH] refactor(facets): pass the facet request as one array computeFacetsForRequest took the object service plus schema, filters, search and organisation as five parameters. The four request values now travel as one array; the steps it runs and the values they receive are unchanged. Assisted-by: ClaudeCode:claude-opus-5-5 --- lib/Service/FacetService.php | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/Service/FacetService.php b/lib/Service/FacetService.php index a2af905d3..882002348 100644 --- a/lib/Service/FacetService.php +++ b/lib/Service/FacetService.php @@ -197,10 +197,12 @@ public function getFacets(string $schema, array $filters = [], ?string $search = $result = $this->computeFacetsForRequest( objectService: $objectService, - schema: $schema, - normalizedFilters: $normalizedFilters, - normalizedSearch: $normalizedSearch, - organization: $organization + request: [ + 'schema' => $schema, + 'filters' => $normalizedFilters, + 'search' => $normalizedSearch, + 'organization' => $organization, + ] ); $this->facetsCache->set(key: $cacheKey, value: $result, ttl: self::CACHE_TTL); @@ -237,29 +239,23 @@ private function assertSupportedSchema(string $schema): void { * (including `_meta.matchedObjectIds` for the frontend's list narrowing). * * @param ObjectServiceInterface $objectService OpenRegister object service. - * @param string $schema `module` or `dienst`. - * @param array $normalizedFilters Normalized selected filters. - * @param string|null $normalizedSearch Normalized free-text query. - * @param string|null $organization Optional organisation override. + * @param array $request The request: `schema` (`module` or `dienst`), `filters` (the normalized + * selected filters), `search` (the normalized free-text query or null) and + * `organization` (the optional organisation override). * * @return array{referenceComponent: array, standard: array, applicationService: array, * domain: array, _meta: array{totalMatched: int, processingTimeMs: float, cached: bool, * matchedObjectIds: string[]}} */ - private function computeFacetsForRequest( - ObjectServiceInterface $objectService, - string $schema, - array $normalizedFilters, - ?string $normalizedSearch, - ?string $organization, - ): array { + private function computeFacetsForRequest(ObjectServiceInterface $objectService, array $request): array { $startTime = microtime(true); + $schema = $request['schema']; $baseObjects = $this->fetchBaseObjects( objectService: $objectService, schema: $schema, - search: $normalizedSearch, - organization: $organization + search: $request['search'], + organization: $request['organization'] ); $modulesByObjectId = $this->resolveModulesPerObject( @@ -272,12 +268,12 @@ private function computeFacetsForRequest( $facets = $this->computeFacets( dimValsByObjId: $dimValsByObjId, - selectedFilters: $normalizedFilters + selectedFilters: $request['filters'] ); $matchedObjectIds = $this->filterObjectIds( dimValsByObjId: $dimValsByObjId, - selectedFilters: $normalizedFilters, + selectedFilters: $request['filters'], excludeDimension: null );