public function LearningPathManagerController::getItemTypes in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathManagerController.php \Drupal\opigno_learning_path\Controller\LearningPathManagerController::getItemTypes()
Return content types available for learning paths.
1 string reference to 'LearningPathManagerController::getItemTypes'
File
- src/
Controller/ LearningPathManagerController.php, line 511
Class
- LearningPathManagerController
- Controller for all the actions of the Learning Path manager app.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getItemTypes($mainItem = NULL, $json_output = TRUE) {
// Init the return array and get all the content types available.
$available_types = [];
$content_types_definitions = $this->content_types_manager
->getDefinitions();
// For each content type available,
// convert it to an array and store it in the return array.
foreach ($content_types_definitions as $content_type_definition) {
$available_types[] = [
'bundle' => $content_type_definition['id'],
'contentType' => $content_type_definition['id'],
'name' => $content_type_definition['readable_name'],
];
}
// If a JSON response is asked, return JSON.
// Else, return the array.
if ($json_output) {
return new JsonResponse($available_types, Response::HTTP_OK);
}
else {
return $available_types;
}
}