public function OpignoGroupManagerController::updateGuidedNavigation in Opigno group manager 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoGroupManagerController.php \Drupal\opigno_group_manager\Controller\OpignoGroupManagerController::updateGuidedNavigation()
Update Learning Path guided navigation field.
Parameters
\Drupal\group\Entity\Group $group: Group object.
\Symfony\Component\HttpFoundation\Request $request: Request array.
Return value
\Symfony\Component\HttpFoundation\JsonResponse Response array.
1 string reference to 'OpignoGroupManagerController::updateGuidedNavigation'
File
- src/
Controller/ OpignoGroupManagerController.php, line 915
Class
- OpignoGroupManagerController
- Controller for all the actions of the Opigno group manager app.
Namespace
Drupal\opigno_group_manager\ControllerCode
public function updateGuidedNavigation(Group $group, Request $request) {
$data = json_decode($request
->getContent());
if (!isset($data->guidedNavigation)) {
return new JsonResponse(NULL, Response::HTTP_BAD_REQUEST);
}
$guidedNavigation = 0;
if ($group
->hasField('field_guided_navigation')) {
$guidedNavigation = $data->guidedNavigation;
$group
->set('field_guided_navigation', $guidedNavigation);
try {
$group
->save();
} catch (EntityStorageException $e) {
return new JsonResponse(NULL, Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
return new JsonResponse([
'guidedNavigation' => $guidedNavigation,
], Response::HTTP_OK);
}