public function insert(array $data) { if (isset($data['userId']) && !$data['userId'] instanceof \Domain\User\Entity\User) { $data['userId'] = $this->getEm()->getRepository("Domain\\User\\Entity\\User")->find($data['userId']); } $data['token'] = $this->cryptService->hash(time(), $data['userId']->getSalt()); $data['access'] = $this->cryptService->hash(time() * 2, $data['userId']->getSalt()); $this->response = parent::insert($data); if ($this->response['status']) { $this->response['data'] = $this->response['data']->toArray(); } return $this->response; }
public function insert(array $data) { if (!isset($data['myUri']) || !$data['myUri']) { $data['myUri'] = $this->generateMyUri->generate($data['name']); } if ($this->getEm()->getRepository($this->entity)->findOneByEmail($data['email'])) { $this->response['messages'] = ['Email ja consta em nosso banco de dados']; $this->response['status'] = false; return $this->response; } if (isset($data['password']) && $data['password']) { $entity = new $this->entity(); $data['salt'] = $entity->getSalt(); $data['password'] = $this->cryptService->hash($data['password'], $data['salt']); } $this->response = parent::insert($data); if ($this->response['status']) { $this->response['data'] = $this->response['data']->toArrayApi(); } return $this->response; }