コード例 #1
0
 /**
  * Blah
  *
  */
 public function attachMissingUserProfileValues(UserProfile $userProfile)
 {
     $fields = $this->em->getRepository('CrisisTextLineUserProfileBundle:UserProfileField')->findAll();
     foreach ($fields as $field) {
         if ($userProfile->hasValueForField($field) == false) {
             $default = $field->getDefaultValue();
             $value = new UserProfileValue($userProfile, $field, $default);
             $userProfile->addValue($value);
             $this->em->persist($userProfile);
             $this->em->persist($value);
         }
     }
     $this->em->flush();
     return $userProfile;
 }
コード例 #2
0
 /**
  * Set the profile's values according to field name and jsonified values in incoming array
  *
  * @param UserProfile $profile
  * @param array $dataArray
  */
 private function setProfileValues($profile, $dataArray)
 {
     foreach ($dataArray as $fieldName => $jsonValue) {
         $value = $this->valueRepo->findOneBy(array('userProfile' => $profile, 'userProfileField' => $this->fieldRepo->findOneByName($fieldName)));
         $value->setValue($jsonValue);
         $this->em->persist($value);
     }
     $this->em->flush();
     $this->userCallback['service']->{$this->userCallback['method']}($profile->getUser(), true);
 }