コード例 #1
0
 public function insertPlayerData(\Symfony\Component\Form\Form $form)
 {
     $sportList = $form->get('sports')->getData();
     $this->created = time();
     $player = new Player();
     $gender = $form->get('gender')->getData();
     $player->setName($form->get('name')->getData());
     $player->setLastname($form->get('name')->getData());
     $player->setEmail($form->get('email')->getData());
     $player->setUsername($form->get('email')->getData());
     $player->setPassword(md5($form->get('password')->getData()));
     $player->setBirthday(strtotime($form->get('birthday')->getData()->format('d-m-Y')));
     $player->setSports(implode(':', $sportList));
     $player->setGender($gender->getId());
     $player->setActivityradius(10);
     //default
     $player->setCreated($this->created);
     $player->setPopularity('1');
     //default
     $player->setZipcode($form->get('zipcode')->getData());
     $player->setEvaluate('1');
     //can be modified in administration
     $player->setPlayerstatus(1);
     //can be modified in administration
     $player->setSkills('1:1:1');
     //default
     $player->setRegistered(0);
     $player->setOnline(0);
     $em = $this->getEntityManager();
     $em->persist($player);
     //populate player_sports_skills
     //cross reference table(entity) matches chosen sports with specific skills
     foreach ($sportList as $k => $v) {
         $pss = new PlayerSportsSkills();
         $pss->setPlayerId($player);
         $skill = $this->_em->getRepository("SportnetzwerkSpnBundle:Skilllevels")->findByName('pro');
         ///trigger_error(var_export($skill, true));
         $pss->setSkilllevelsId($skill[0]);
         $sport = $this->_em->getRepository("SportnetzwerkSpnBundle:Sports")->findById($v);
         $pss->setSportsId($sport[0]);
         $emLoop = $this->getEntityManager();
         $emLoop->persist($pss);
         $emLoop->flush();
         unset($pss);
     }
     $em->flush();
 }
コード例 #2
0
 public function load(ObjectManager $manager)
 {
     $Player1 = new Player();
     $Player1->setName('Koko');
     $Player1->setLastname('Mueller');
     $Player1->setEmail('*****@*****.**');
     $Player1->setUsername('*****@*****.**');
     $Player1->setPassword(md5('koko'));
     $Player1->setBirthday(time());
     $Player1->setSports('1:2:4');
     $Player1->setGender(1);
     $Player1->setActivityradius(10);
     $Player1->setCreated(time());
     $Player1->setPopularity('bu');
     $Player1->setZipcode("56667");
     $Player1->setEvaluate('1');
     $Player1->setPlayerstatus(1);
     $Player1->setSkills('1:1:2');
     $Player1->setRegistered(1);
     $Player1->setOnline(0);
     $manager->persist($Player1);
     $manager->flush();
     $this->addReference('Player1', $Player1);
 }