public function LearningPathManagerController::getAvailableItems in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathManagerController.php \Drupal\opigno_learning_path\Controller\LearningPathManagerController::getAvailableItems()
Return contents availables when you want add content to learning path.
1 string reference to 'LearningPathManagerController::getAvailableItems'
File
- src/
Controller/ LearningPathManagerController.php, line 486
Class
- LearningPathManagerController
- Controller for all the actions of the Learning Path manager app.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getAvailableItems($mainItem = NULL) {
// Init the return array and get all the content types available.
$available_contents = [];
$content_types_definitions = $this->content_types_manager
->getDefinitions();
// For each content type,
// get the available contents from them and store it in the return array.
foreach ($content_types_definitions as $content_type_id => $content_type_definition) {
// Get the available contents from the content type.
$content_type = $this->content_types_manager
->createInstance($content_type_id);
$content_type_contents = $content_type
->getAvailableContents();
// For each content, convert it to an array.
foreach ($content_type_contents as $content_type_content) {
$available_contents[] = $content_type_content
->toManagerArray();
}
}
// Return the available contents in JSON.
return new JsonResponse($available_contents, Response::HTTP_OK);
}