Пример #1
0
 public function save(Entity $entity)
 {
     $data = $this->hydrator->extract($entity);
     $id = $this->getEntityManager()->getAdapter()->save($entity, $data);
     if (!$id) {
         $id = $entity->getId();
     }
     $savedEntity = $this->find($id);
     $savedData = $this->hydrator->extract($savedEntity);
     $this->hydrator->hydrate($savedData, $entity);
 }
Пример #2
0
 public function hydrate(array $data, $entity)
 {
     /** @var \EvaUser\Entity\User $entity */
     parent::hydrate($data, $entity);
     $entity->setPassword($data['password']);
     $human = new Human();
     $human->setFirstName($data['firstName']);
     $human->setUser($entity);
     $entity->setHuman($human);
     $phoneNumber = new PhoneNumber();
     $phoneNumber->setNumber($data['phone']);
     $phoneNumber->setHuman($human);
     $human->setPhoneNumbers([$phoneNumber]);
     $emailAddress = new EmailAddress();
     $emailAddress->setAddress($data['email']);
     $emailAddress->setHuman($human);
     $human->setEmailAddresses([$emailAddress]);
 }