public function DashboardController::setDefaultPositioning in Opigno dashboard 3.x
Same name and namespace in other branches
- 8 src/Controller/DashboardController.php \Drupal\opigno_dashboard\Controller\DashboardController::setDefaultPositioning()
Sets default positioning.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
1 string reference to 'DashboardController::setDefaultPositioning'
File
- src/
Controller/ DashboardController.php, line 189
Class
- DashboardController
- Controller for all the actions of the Learning Path manager app.
Namespace
Drupal\opigno_dashboard\ControllerCode
public function setDefaultPositioning(Request $request) : JsonResponse {
$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 = $this->configFactory
->getEditable('opigno_dashboard.default.settings');
$config
->set('positions', json_encode($datas->positions));
$config
->set('columns', (int) $datas->columns);
$config
->save();
} catch (\Exception $e) {
watchdog_exception('opigno_dashboard_exception', $e);
$this->messenger
->addMessage($e
->getMessage(), 'error');
}
return new JsonResponse();
}