public function updateAction(Request $request, $id)
    {
        $class_name = $this->container->getParameter('acs_settings.setting_class');
        $settingmanager = $this->get('acs.setting_manager');
        $user_fields = $settingmanager->loadUserFields();
        $em = $this->getDoctrine()->getManager();

        $entity = $this->get('security.context')->getToken()->getUser();

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find ConfigSetting entity.');
        }

        $editForm = $this->createForm(new ConfigSettingCollectionType($user_fields,$em), $entity);

        $editForm->bind($request);


        $postData = $request->request->get('acs_settings_usersettings');

        if ($editForm->isValid()) {
            if (isset($postData['settings'])) {
                    $settings = $postData['settings'];

                    foreach ($settings as $setting) {
                        $args = array(
                            'user' => $entity->getId(),
                            'setting_key' => $setting['setting_key'],
                        );

                        if(isset($setting['service_id'])){
                            $service = $em->getRepository('ACSACSPanelBundle:Service')->find($setting['service_id']);
                            $args['service'] = $service;
                        }

                        $panelsetting = $em->getRepository('ACSACSPanelBundle:PanelSetting')->findOneBy($args);

                        if ($panelsetting && isset($setting['value'])) {
                            $panelsetting->setValue($setting['value']);
                            $em->persist($panelsetting);
                            $em->flush();
                        }
                    }
                    $em->flush();
            }
            return $this->redirect($this->generateUrl('settings'));
        }

        return $this->render('ACSACSPanelSettingsBundle:ConfigSetting:new.html.twig', array(
            'entity' => $entity,
            'form'   => $editForm->createView(),
        ));
    }
public function updateAction(Request $request, $id)
    {
        $class_name = $this->container->getParameter('acs_settings.setting_class');
        $settingmanager = $this->get('acs.setting_manager');
        $user_fields = $settingmanager->loadUserFields();
        $em = $this->getDoctrine()->getManager();

        $entity = $this->get('security.context')->getToken()->getUser();

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find ConfigSetting entity.');
        }

        $editForm = $this->createForm(new ConfigSettingCollectionType($user_fields,$em), $entity);

        $editForm->bind($request);


        $postData = $request->request->get('acs_settings_usersettings');

        if ($editForm->isValid()) {
            if (isset($postData['settings'])) {
                    $settings = $postData['settings'];

                    foreach ($settings as $setting) {
                        $args = array(
                            'user' => $entity->getId(),
                            'setting_key' => $setting['setting_key'],
                        );

                        if(isset($setting['service_id'])){
                            $service = $em->getRepository('ACSACSPanelBundle:Service')->find($setting['service_id']);
                            $args['service'] = $service;
                        }

                        $panelsetting = $em->getRepository('ACSACSPanelBundle:PanelSetting')->findOneBy($args);

                        if ($panelsetting && isset($setting['value'])) {
                            $panelsetting->setValue($setting['value']);
                            $em->persist($panelsetting);
                            $em->flush();
                        }
                    }
                    $em->flush();
            }
            return $this->redirect($this->generateUrl('settings'));
        }

        return $this->render('ACSACSPanelSettingsBundle:ConfigSetting:new.html.twig', array(
            'entity' => $entity,
            'form'   => $editForm->createView(),
        ));
    }
public function updateAction ( Request $ request , $ id ) { $ class_name = $ this -> container -> getParameter ( 'acs_settings.setting_class' ) ; $ settingmanager = $ this -> get ( 'acs.setting_manager' ) ; $ user_fields = $ settingmanager -> loadUserFields ( ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find ConfigSetting entity.' ) ; } $ editForm = $ this -> createForm ( new ConfigSettingCollectionType ( $ user_fields , $ em ) , $ entity ) ; $ editForm -> bind ( $ request ) ; $ postData = $ request -> request -> get ( 'acs_settings_usersettings' ) ; if ( $ editForm -> isValid ( ) ) { if ( isset ( $ postData [ 'settings' ] ) ) { $ settings = $ postData [ 'settings' ] ; foreach ( $ settings as $ setting ) { $ args = array ( 'user' => $ entity -> getId ( ) , 'setting_key' => $ setting [ 'setting_key' ] , ) ; if ( isset ( $ setting [ 'service_id' ] ) ) { $ service = $ em -> getRepository ( 'ACSACSPanelBundle:Service' ) -> find ( $ setting [ 'service_id' ] ) ; $ args [ 'service' ] = $ service ; } $ panelsetting = $ em -> getRepository ( 'ACSACSPanelBundle:PanelSetting' ) -> findOneBy ( $ args ) ; if ( $ panelsetting && isset ( $ setting [ 'value' ] ) ) { $ panelsetting -> setValue ( $ setting [ 'value' ] ) ; $ em -> persist ( $ panelsetting ) ; $ em -> flush ( ) ; } } $ em -> flush ( ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'settings' ) ) ; } return $ this -> render ( 'ACSACSPanelSettingsBundle:ConfigSetting:new.html.twig' , array ( 'entity' => $ entity , 'form' => $ editForm -> createView ( ) , ) ) ; }
Edits an existing ConfigSetting entity.
Edits an existing ConfigSetting entity .