logger = $logger; $this->userSession = $userSession; $this->relatedService = $relatedService; $this->configService = $configService; try { $this->circlesManager = Server::get(CirclesManager::class); } catch (ContainerExceptionInterface|AutoloadNotAllowedException $e) { } } /** * @NoAdminRequired * * @param string $providerId * @param string $itemId * @param string $resourceType * @return DataResponse * @throws OCSException */ public function getRelatedResources( string $providerId, string $itemId, int $limit = 0, string $resourceType = '', ): DataResponse { if (is_null($this->circlesManager)) { $this->logger->info('RelatedResources require Circles'); return new DataResponse([]); } $limit = ($limit > 0) ? $limit : $this->configService->getAppValueInt(ConfigService::RESULT_MAX); try { $this->circlesManager->startSession(); $result = $this->relatedService->getRelatedToItem( $providerId, $itemId, $limit, $resourceType ); // cleanData on result, to not send useless data. $new = []; foreach ($result as $related) { $new[] = RelatedResource::cleanData($this->serialize($related)); } return new DataResponse($new); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new OCSException( ($e->getMessage() === '') ? get_class($e) : $e->getMessage(), Http::STATUS_BAD_REQUEST ); } } }