topic->content->S)) {
returnServerError('Failed to retrieve valid JSON data');
}
$data = json_decode($jsonData->topic->content->S);
// Constructing the content in an array
$contentArray = [];
$contentArray[] = "
Introduction
$data->introduction
";
$contentArray[] = "Overview
$data->overview
";
$contentArray[] = "Importance
$data->importance
";
$contentArray[] = "Historical Context
$data->historicalContext
";
$contentArray[] = "Use Cases
- " . implode("
- ", $data->useCases) . "
";
$contentArray[] = "Pros
- " . implode("
- ", $data->pros) . "
";
$contentArray[] = "Cons
- " . implode("
- ", $data->cons) . "
";
$contentArray[] = "Key Takeaways
- " . implode("
- ", $data->keyTakeaways) . "
";
// Concatenate array elements into a single string
$content = implode('', $contentArray);
// Assigning to items
$this->items[] = [
'title' => $data->title,
'content' => $content,
'url' => self::URI,
'uid' => $jsonData->topic->id->S,
];
}
}