Controller/ConfigSettingController.php
public function createObjectSettingsAction($object_id)
    {
        $em = $this->getDoctrine()->getManager();
        $class_name = $this->container->getParameter('acs_settings.setting_class');

        // Get the object fields
        $object = $em->getRepository('ACSACSPanelBundle:Service')->find($object_id);
        $object_fields = $object->getType()->getFieldTypes();

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

        // Adding one form for each setting field
        foreach($object_fields as $id => $field_config){
            $setting = $em->getRepository('ACSACSPanelBundle:PanelSetting')->findOneBy(
                array(
                    'user' => $user->getId(),
                    'setting_key' => $field_config->getSettingKey(),
                    'focus' => 'object_setting',
                    'service' => $object,
                )
            );

            if (!count($setting)) {
                $setting = new $class_name;
                $setting->setSettingKey($field_config->getSettingKey());
                $setting->setValue($field_config->getDefaultValue());
                $setting->setContext($field_config->getContext());
                $setting->setLabel($field_config->getLabel());
                $setting->setType($field_config->getType());
                $setting->setFocus('object_setting');
                $setting->setService($object);
                $user->addSetting($setting);
                $em->persist($user);
                $em->flush();
            }
        }

        return $this->redirect($this->generateUrl('settings'));
    }
public function createObjectSettingsAction($object_id)
    {
        $em = $this->getDoctrine()->getManager();
        $class_name = $this->container->getParameter('acs_settings.setting_class');

        // Get the object fields
        $object = $em->getRepository('ACSACSPanelBundle:Service')->find($object_id);
        $object_fields = $object->getType()->getFieldTypes();

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

        // Adding one form for each setting field
        foreach($object_fields as $id => $field_config){
            $setting = $em->getRepository('ACSACSPanelBundle:PanelSetting')->findOneBy(
                array(
                    'user' => $user->getId(),
                    'setting_key' => $field_config->getSettingKey(),
                    'focus' => 'object_setting',
                    'service' => $object,
                )
            );

            if (!count($setting)) {
                $setting = new $class_name;
                $setting->setSettingKey($field_config->getSettingKey());
                $setting->setValue($field_config->getDefaultValue());
                $setting->setContext($field_config->getContext());
                $setting->setLabel($field_config->getLabel());
                $setting->setType($field_config->getType());
                $setting->setFocus('object_setting');
                $setting->setService($object);
                $user->addSetting($setting);
                $em->persist($user);
                $em->flush();
            }
        }

        return $this->redirect($this->generateUrl('settings'));
    }
public function createObjectSettingsAction ( $ object_id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ class_name = $ this -> container -> getParameter ( 'acs_settings.setting_class' ) ; // Get the object fields $ object = $ em -> getRepository ( 'ACSACSPanelBundle:Service' ) -> find ( $ object_id ) ; $ object_fields = $ object -> getType ( ) -> getFieldTypes ( ) ; $ user = $ this -> get ( 'security.context' ) -> getToken ( ) -> getUser ( ) ; // Adding one form for each setting field foreach ( $ object_fields as $ id => $ field_config ) { $ setting = $ em -> getRepository ( 'ACSACSPanelBundle:PanelSetting' ) -> findOneBy ( array ( 'user' => $ user -> getId ( ) , 'setting_key' => $ field_config -> getSettingKey ( ) , 'focus' => 'object_setting' , 'service' => $ object , ) ) ; if ( ! count ( $ setting ) ) { $ setting = new $ class_name ; $ setting -> setSettingKey ( $ field_config -> getSettingKey ( ) ) ; $ setting -> setValue ( $ field_config -> getDefaultValue ( ) ) ; $ setting -> setContext ( $ field_config -> getContext ( ) ) ; $ setting -> setLabel ( $ field_config -> getLabel ( ) ) ; $ setting -> setType ( $ field_config -> getType ( ) ) ; $ setting -> setFocus ( 'object_setting' ) ; $ setting -> setService ( $ object ) ; $ user -> addSetting ( $ setting ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; } } return $ this -> redirect ( $ this -> generateUrl ( 'settings' ) ) ; }
It creates the object settings specified
It creates the object settings specified