public function OpignoModuleManagerController::activityUpdateWeight in Opigno module 8
Same name and namespace in other branches
- 3.x src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::activityUpdateWeight()
Update activity weight.
1 string reference to 'OpignoModuleManagerController::activityUpdateWeight'
File
- src/
Controller/ OpignoModuleManagerController.php, line 610
Class
- OpignoModuleManagerController
- Controller for all the actions of the Opigno module manager.
Namespace
Drupal\opigno_module\ControllerCode
public function activityUpdateWeight(Request $request) {
$datas = json_decode($request
->getContent());
if (empty($datas->acitivies_weight)) {
return new JsonResponse(NULL, Response::HTTP_BAD_REQUEST);
}
$db_connection = \Drupal::service('database');
foreach ($datas->acitivies_weight as $value) {
$db_connection
->merge('opigno_module_relationship')
->keys([
'omr_id' => $value->omr_id,
])
->fields([
'weight' => $value->weight,
])
->execute();
}
return new JsonResponse(NULL, Response::HTTP_OK);
}