public function OpignoGroupManagerController::updateItemMandatory in Opigno group manager 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoGroupManagerController.php \Drupal\opigno_group_manager\Controller\OpignoGroupManagerController::updateItemMandatory()
Method called when a step is set as mandatory or not.
1 string reference to 'OpignoGroupManagerController::updateItemMandatory'
File
- src/
Controller/ OpignoGroupManagerController.php, line 341
Class
- OpignoGroupManagerController
- Controller for all the actions of the Opigno group manager app.
Namespace
Drupal\opigno_group_manager\ControllerCode
public function updateItemMandatory(Group $group, Request $request) {
// Get the data and ensure that all data are okay.
$datas = json_decode($request
->getContent());
if (empty($datas->cid) || isset($datas->isMandatory) === FALSE) {
return new JsonResponse(NULL, Response::HTTP_BAD_REQUEST);
}
$cid = $datas->cid;
$mandatory = $datas->isMandatory;
// Load the good content, update it and save it.
$content = OpignoGroupManagedContent::load($cid);
$content
->setMandatory($mandatory);
$content
->save();
// Finally, return the JSON response.
return new JsonResponse(NULL, Response::HTTP_OK);
}