Skip to content

Commit cf631fc

Browse files
committed
feat(DotCMSService): Enhance getPage method to support additional query parameters
- Updated getPage method to accept languageId, mode, personaId, and publishDate. - Modified CatchAllController to utilize new parameters for improved page requests.
1 parent 1503662 commit cf631fc

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

examples/dotcms-symfony/src/Controller/CatchAllController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ public function show(string $path = ''): Response
2727
try {
2828
$request = $this->container->get('request_stack')->getCurrentRequest();
2929
$actualPath = $request->getPathInfo();
30-
$pageAsset = $this->dotCMSService->getPage($actualPath);
30+
31+
$languageId = $request->query->get('language_id');
32+
$mode = $request->query->get('mode');
33+
$personaId = $request->query->get('personaId');
34+
$publishDate = $request->query->get('publishDate');
35+
36+
$pageAsset = $this->dotCMSService->getPage(
37+
$actualPath,
38+
$languageId ? (int)$languageId : null,
39+
$mode,
40+
$personaId,
41+
$publishDate
42+
);
3143

3244
if (!$pageAsset || !isset($pageAsset->page)) {
3345
throw new NotFoundHttpException('Page not found');

examples/dotcms-symfony/src/Service/DotCMSService.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,38 @@ public function getClient(): DotCMSClient
2020
return $this->client;
2121
}
2222

23-
// Add any common DotCMS operations here as methods
24-
// For example:
25-
public function getPage(string $path): PageAsset
26-
{
23+
/**
24+
* Get a page from DotCMS
25+
*
26+
* @param string $path The path of the page
27+
* @param int|null $languageId The language ID
28+
* @param string|null $mode The mode (live, edit, preview)
29+
* @param string|null $personaId The persona ID
30+
* @param string|null $publishDate The publish date
31+
* @return PageAsset
32+
*/
33+
public function getPage(
34+
string $path,
35+
?int $languageId = null,
36+
?string $mode = null,
37+
?string $personaId = null,
38+
?string $publishDate = null
39+
): PageAsset {
2740
$pageRequest = $this->client->createPageRequest($path, 'json');
2841

42+
if ($languageId) {
43+
$pageRequest = $pageRequest->withLanguageId($languageId);
44+
}
45+
if ($mode) {
46+
$pageRequest = $pageRequest->withMode($mode);
47+
}
48+
if ($personaId) {
49+
$pageRequest = $pageRequest->withPersonaId($personaId);
50+
}
51+
if ($publishDate) {
52+
$pageRequest = $pageRequest->withPublishDate($publishDate);
53+
}
54+
2955
return $this->client->getPage($pageRequest);
3056
}
3157

0 commit comments

Comments
 (0)