Skip to content

Commit b7bf262

Browse files
committed
feat(dotcms-laravel): Enhance AppController and PageRequest for additional query parameters
- Added support for language_id, mode, personaId, and publishDate in AppController. - Updated PageRequest to include publishDate with validation for ISO 8601 format. - Adjusted request handling to incorporate new parameters for improved page requests.
1 parent 86c5a64 commit b7bf262

4 files changed

Lines changed: 8770 additions & 3 deletions

File tree

examples/dotcms-laravel/app/Http/Controllers/AppController.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,30 @@ public function index(Request $request)
3434
$path = $request->path();
3535
$path = $path === '/' ? '/' : '/' . $path;
3636

37+
// Get query parameters
38+
$languageId = $request->query('language_id');
39+
$mode = $request->query('mode');
40+
$publishDate = $request->query('publishDate');
41+
$personaId = $request->query('personaId');
42+
3743
// Create a page request for the current path
3844
$pageRequest = $this->dotCMSClient->createPageRequest($path, 'json');
3945

46+
// Add query parameters if they exist
47+
if ($languageId) {
48+
$pageRequest = $pageRequest->withLanguageId((int)$languageId);
49+
}
50+
if ($mode) {
51+
$pageRequest = $pageRequest->withMode($mode);
52+
}
53+
if ($personaId) {
54+
$pageRequest = $pageRequest->withPersonaId($personaId);
55+
}
56+
57+
if ($publishDate) {
58+
$pageRequest = $pageRequest->withPublishDate($publishDate);
59+
}
60+
4061
// Get the page data
4162
$pageAsset = $this->dotCMSClient->getPage($pageRequest);
4263

@@ -65,7 +86,8 @@ public function index(Request $request)
6586
// Pass the data to the view
6687
return view('page', [
6788
'pageAsset' => $page,
68-
'navigation' => $nav
89+
'navigation' => $nav,
90+
'publishDate' => $publishDate
6991
]);
7092
} catch (\Exception $e) {
7193
// Log the error
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"$schema": "https://getcomposer.org/schema.json",
3+
"name": "laravel/laravel",
4+
"type": "project",
5+
"description": "The skeleton application for the Laravel framework.",
6+
"keywords": [
7+
"laravel",
8+
"framework"
9+
],
10+
"license": "MIT",
11+
"repositories": [
12+
{
13+
"type": "path",
14+
"url": "../../"
15+
}
16+
],
17+
"require": {
18+
"php": "^8.2",
19+
"dotcms/php-sdk": "dev-main",
20+
"laravel/framework": "^12.0",
21+
"laravel/tinker": "^2.10.1"
22+
},
23+
"require-dev": {
24+
"fakerphp/faker": "^1.23",
25+
"laravel/pail": "^1.2.2",
26+
"laravel/pint": "^1.13",
27+
"laravel/sail": "^1.41",
28+
"mockery/mockery": "^1.6",
29+
"nunomaduro/collision": "^8.6",
30+
"phpunit/phpunit": "^11.5.3"
31+
},
32+
"autoload": {
33+
"psr-4": {
34+
"App\\": "app/",
35+
"Database\\Factories\\": "database/factories/",
36+
"Database\\Seeders\\": "database/seeders/"
37+
}
38+
},
39+
"autoload-dev": {
40+
"psr-4": {
41+
"Tests\\": "tests/"
42+
}
43+
},
44+
"scripts": {
45+
"post-autoload-dump": [
46+
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
47+
"@php artisan package:discover --ansi"
48+
],
49+
"post-update-cmd": [
50+
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
51+
],
52+
"post-root-package-install": [
53+
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
54+
],
55+
"post-create-project-cmd": [
56+
"@php artisan key:generate --ansi",
57+
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
58+
"@php artisan migrate --graceful --ansi"
59+
],
60+
"dev": [
61+
"Composer\\Config::disableProcessTimeout",
62+
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
63+
]
64+
},
65+
"extra": {
66+
"laravel": {
67+
"dont-discover": []
68+
}
69+
},
70+
"config": {
71+
"optimize-autoloader": true,
72+
"preferred-install": "dist",
73+
"sort-packages": true,
74+
"allow-plugins": {
75+
"pestphp/pest-plugin": true,
76+
"php-http/discovery": true
77+
}
78+
},
79+
"minimum-stability": "stable",
80+
"prefer-stable": true
81+
}

0 commit comments

Comments
 (0)