public function DashboardController::setDefaultPositioning in Opigno dashboard 8
Same name and namespace in other branches
- 3.x src/Controller/DashboardController.php \Drupal\opigno_dashboard\Controller\DashboardController::setDefaultPositioning()
Sets default positioning.
1 string reference to 'DashboardController::setDefaultPositioning'
File
- src/
Controller/ DashboardController.php, line 224
Class
- DashboardController
- Controller for all the actions of the Learning Path manager app.
Namespace
Drupal\opigno_dashboard\ControllerCode
public function setDefaultPositioning(Request $request) {
$datas = json_decode($request
->getContent());
unset($datas->positions[0]);
// Fix critical symbols.
if (!empty($datas->positions)) {
foreach ($datas->positions as &$position) {
if (!empty($position)) {
foreach ($position as &$block) {
$block->admin_label = str_replace("'", "`", $block->admin_label);
}
}
}
}
try {
$config = \Drupal::configFactory()
->getEditable('opigno_dashboard.default.settings');
$config
->set('positions', json_encode($datas->positions));
$config
->set('columns', (int) $datas->columns);
$config
->save();
} catch (\Exception $e) {
\Drupal::logger('opigno_dashboard')
->error($e
->getMessage());
\Drupal::messenger()
->addMessage($e
->getMessage(), 'error');
}
return new JsonResponse(NULL, Response::HTTP_OK);
}