original_string: 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'));
      }
code: 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'));
      }
code_tokens: 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' ) ) ; }
docstring: It creates the object settings specified
docstring_tokens: It creates the object settings specified