From 16d63d7ca2067a0192b0f29f991e50ffa87e1ffd Mon Sep 17 00:00:00 2001 From: Purushotam Rai Date: Tue, 28 May 2024 12:43:47 +0200 Subject: [PATCH] PCC-61: Allowing query args in debug endpoint. (#10) --- src/Controller/DebugSiteController.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Controller/DebugSiteController.php b/src/Controller/DebugSiteController.php index 564a884..ded3034 100644 --- a/src/Controller/DebugSiteController.php +++ b/src/Controller/DebugSiteController.php @@ -6,6 +6,9 @@ use PccPhpSdk\api\ArticlesApi; use PccPhpSdk\api\Query\ArticleQueryArgs; use PccPhpSdk\api\Query\ArticleSearchArgs; +use PccPhpSdk\api\Query\Enums\ArticleSortField; +use PccPhpSdk\api\Query\Enums\ArticleSortOrder; +use PccPhpSdk\api\Query\Enums\ContentType; use PccPhpSdk\api\Query\Enums\PublishStatus; use PccPhpSdk\api\SitesApi; use PccPhpSdk\core\PccClient; @@ -153,7 +156,15 @@ public function getArticleBySlug(string $slug): JsonResponse { */ public function searchArticles(): JsonResponse { $contentApi = new ArticlesApi($this->pccClient); - $response = $contentApi->searchArticles(new ArticleQueryArgs(), new ArticleSearchArgs( + $response = $contentApi->searchArticles( + new ArticleQueryArgs( + ArticleSortField::from($this->getQueryArg('sortField') ?? 'updatedAt'), + ArticleSortOrder::from($this->getQueryArg('sortOrder') ?? 'DESC'), + $this->getQueryArg('pageSize') ?? 10, + $this->getQueryArg('pageIndex') ?? 1, + ContentType::from($this->getQueryArg('contentType') ?? 'TREE_PANTHEON_V2') + ), + new ArticleSearchArgs( $this->getQueryArg('bodyContains') ?? '', $this->getQueryArg('tagContains') ?? '', $this->getQueryArg('titleContains') ?? '',