|
7 | 7 |
|
8 | 8 | // Create a configuration |
9 | 9 | $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', |
12 | 12 | ); |
13 | 13 |
|
14 | 14 | // Create a client |
|
19 | 19 | echo "--------------------------------\n"; |
20 | 20 | $navRequest = $client->createNavigationRequest('/', 1); |
21 | 21 | $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"; |
25 | 25 |
|
26 | 26 | // Example 2: Get navigation with children (depth=2) |
27 | 27 | echo "Example 2: Navigation with children (depth=2)\n"; |
28 | 28 | echo "------------------------------------------\n"; |
29 | | -$navWithChildrenRequest = $client->createNavigationRequest('/about-us', 2); |
| 29 | +$navWithChildrenRequest = $client->createNavigationRequest('/application', 2); |
30 | 30 | $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"; |
34 | 34 |
|
35 | 35 | if ($navWithChildren->hasChildren()) { |
36 | 36 | echo "Children:\n"; |
37 | 37 | foreach ($navWithChildren->getChildren() as $child) { |
38 | | - echo "- " . $child['title'] . " (" . $child['href'] . ")\n"; |
| 38 | + echo "- " . $child->title . " (" . $child->href . ")\n"; |
39 | 39 | } |
40 | 40 | } |
41 | 41 | echo "\n"; |
|
45 | 45 | echo "-------------------------------------------\n"; |
46 | 46 | $navSpanishRequest = $client->createNavigationRequest('/', 1, 2); |
47 | 47 | $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"; |
51 | 51 |
|
52 | 52 | // Example 4: Async navigation request |
53 | 53 | echo "Example 4: Async navigation request\n"; |
54 | 54 | echo "--------------------------------\n"; |
55 | | -$asyncRequest = $client->createNavigationRequest('/about-us', 2); |
| 55 | +$asyncRequest = $client->createNavigationRequest('/application', 2); |
56 | 56 | $client->getNavigationAsync($asyncRequest)->then( |
57 | 57 | function ($nav) { |
58 | | - echo "Title: " . $nav['title'] . "\n"; |
| 58 | + echo "Title: " . $nav->title . "\n"; |
59 | 59 | if ($nav->hasChildren()) { |
60 | 60 | echo "Children:\n"; |
61 | 61 | foreach ($nav->getChildren() as $child) { |
62 | | - echo "- " . $child['title'] . "\n"; |
| 62 | + echo "- " . $child->title . "\n"; |
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
|
0 commit comments