public function submitAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $data = $request->get('setting');

            if (!empty($data['value']) && !is_string($data['value'])) {
                $data['value'] = json_encode($data['value']);
            }

            if ($request->get('force')) {
                $name = $request->get('name');
                $manager->update($name, $data);
            } else {
                $manager->create($data);
            }

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred! Something is wrong with provided data. '.
                        'Please try to submit form again.'
                ]
            );
        }
    }
public function submitAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $data = $request->get('setting');

            if (!empty($data['value']) && !is_string($data['value'])) {
                $data['value'] = json_encode($data['value']);
            }

            if ($request->get('force')) {
                $name = $request->get('name');
                $manager->update($name, $data);
            } else {
                $manager->create($data);
            }

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred! Something is wrong with provided data. '.
                        'Please try to submit form again.'
                ]
            );
        }
    }
public function submitAction ( Request $ request ) { try { $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; $ data = $ request -> get ( 'setting' ) ; if ( ! empty ( $ data [ 'value' ] ) && ! is_string ( $ data [ 'value' ] ) ) { $ data [ 'value' ] = json_encode ( $ data [ 'value' ] ) ; } if ( $ request -> get ( 'force' ) ) { $ name = $ request -> get ( 'name' ) ; $ manager -> update ( $ name , $ data ) ; } else { $ manager -> create ( $ data ) ; } return new JsonResponse ( [ 'error' => false ] ) ; } catch ( \ Exception $ e ) { return new JsonResponse ( [ 'error' => true , 'message' => 'Error occurred! Something is wrong with provided data. ' . 'Please try to submit form again.' ] ) ; } }
Submit action to create or edit setting if not exists.

@param Request $request

@return JsonResponse
Submit action to create or edit setting if not exists .