Skip to content

Commit e68211c

Browse files
committed
fix(navigation_example): Update navigation example to use object properties and correct API key usage
1 parent 010d210 commit e68211c

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

examples/navigation_example.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
// Create a configuration
99
$config = new Config(
10-
'https://demo.dotcms.com', // host
11-
'your-api-key-here' // apiKey - Replace with your actual API key if needed
10+
host: 'https://demo.dotcms.com',
11+
apiKey: 'API_KEY',
1212
);
1313

1414
// Create a client
@@ -19,23 +19,23 @@
1919
echo "--------------------------------\n";
2020
$navRequest = $client->createNavigationRequest('/', 1);
2121
$nav = $client->getNavigation($navRequest);
22-
echo "Title: " . $nav['title'] . "\n";
23-
echo "URL: " . $nav['href'] . "\n";
24-
echo "Type: " . $nav['type'] . "\n\n";
22+
echo "Title: " . $nav->title . "\n";
23+
echo "URL: " . $nav->href . "\n";
24+
echo "Type: " . $nav->type . "\n\n";
2525

2626
// Example 2: Get navigation with children (depth=2)
2727
echo "Example 2: Navigation with children (depth=2)\n";
2828
echo "------------------------------------------\n";
29-
$navWithChildrenRequest = $client->createNavigationRequest('/about-us', 2);
29+
$navWithChildrenRequest = $client->createNavigationRequest('/application', 2);
3030
$navWithChildren = $client->getNavigation($navWithChildrenRequest);
31-
echo "Title: " . $navWithChildren['title'] . "\n";
32-
echo "URL: " . $navWithChildren['href'] . "\n";
33-
echo "Type: " . $navWithChildren['type'] . "\n";
31+
echo "Title: " . $navWithChildren->title . "\n";
32+
echo "URL: " . $navWithChildren->href . "\n";
33+
echo "Type: " . $navWithChildren->type . "\n";
3434

3535
if ($navWithChildren->hasChildren()) {
3636
echo "Children:\n";
3737
foreach ($navWithChildren->getChildren() as $child) {
38-
echo "- " . $child['title'] . " (" . $child['href'] . ")\n";
38+
echo "- " . $child->title . " (" . $child->href . ")\n";
3939
}
4040
}
4141
echo "\n";
@@ -45,21 +45,21 @@
4545
echo "-------------------------------------------\n";
4646
$navSpanishRequest = $client->createNavigationRequest('/', 1, 2);
4747
$navSpanish = $client->getNavigation($navSpanishRequest);
48-
echo "Title: " . $navSpanish['title'] . "\n";
49-
echo "URL: " . $navSpanish['href'] . "\n";
50-
echo "Language ID: " . $navSpanish['languageId'] . "\n\n";
48+
echo "Title: " . $navSpanish->title . "\n";
49+
echo "URL: " . $navSpanish->href . "\n";
50+
echo "Language ID: " . $navSpanish->languageId . "\n\n";
5151

5252
// Example 4: Async navigation request
5353
echo "Example 4: Async navigation request\n";
5454
echo "--------------------------------\n";
55-
$asyncRequest = $client->createNavigationRequest('/about-us', 2);
55+
$asyncRequest = $client->createNavigationRequest('/application', 2);
5656
$client->getNavigationAsync($asyncRequest)->then(
5757
function ($nav) {
58-
echo "Title: " . $nav['title'] . "\n";
58+
echo "Title: " . $nav->title . "\n";
5959
if ($nav->hasChildren()) {
6060
echo "Children:\n";
6161
foreach ($nav->getChildren() as $child) {
62-
echo "- " . $child['title'] . "\n";
62+
echo "- " . $child->title . "\n";
6363
}
6464
}
6565
}

0 commit comments

Comments
 (0)