public function addChar($data) { $fraction = $this->em->find('riki34GameBundle:Fraction', $data['fractionID']); $specialization = $this->em->find('riki34GameBundle:Specialization', $data['specializationID']); $char = new PlayerChar($fraction, $specialization); $char->setName($data['name']); $char->setSex($data['sex']); $char->setUser($this->user); $errors = $this->validator->validate($char, null, array('create')); if (count($errors) === 0) { $bag = new Bag(); $bag->setChar($char); $this->em->persist($bag); $this->em->persist($char); $this->em->flush(); return $this->response->generateSuccessResponse(); } else { return $this->response->generateErrorResponse($errors); } }
/** * Remove bag * * @param \riki34\GameBundle\Entity\Bag $bag */ public function removeBag(\riki34\GameBundle\Entity\Bag $bag) { $this->bag->removeElement($bag); }
public function getInArray() { return array('id' => $this->id, 'name' => $this->name, 'modelID' => $this->modelID, 'model' => $this->model->getInArray(), 'locationID' => $this->locationID, 'location' => $this->location, 'bagID' => $this->bagID, 'bag' => $this->bag->getInArray(), 'immortal' => $this->immortal, 'locationPoint' => $this->locationPoint, 'typeID' => $this->typeID); }