You are here

public function DashboardController::setPositioning in Opigno dashboard 8

Same name and namespace in other branches
  1. 3.x src/Controller/DashboardController.php \Drupal\opigno_dashboard\Controller\DashboardController::setPositioning()

Sets positioning.

1 string reference to 'DashboardController::setPositioning'
opigno_dashboard.routing.yml in ./opigno_dashboard.routing.yml
opigno_dashboard.routing.yml

File

src/Controller/DashboardController.php, line 173

Class

DashboardController
Controller for all the actions of the Learning Path manager app.

Namespace

Drupal\opigno_dashboard\Controller

Code

public function setPositioning(Request $request) {
  $datas = json_decode($request
    ->getContent());
  $connection = \Drupal::database();

  // Remove first column.
  unset($datas->positions[0]);
  $connection
    ->merge('opigno_dashboard_positioning')
    ->key([
    'uid' => \Drupal::currentUser()
      ->id(),
  ])
    ->fields([
    'columns' => (int) $datas->columns,
  ])
    ->fields([
    'positions' => json_encode($datas->positions),
  ])
    ->execute();
  return new JsonResponse(NULL, Response::HTTP_OK);
}