request->all(); // deshabilito la tenencia $tenancyService = $this->getTenancyService(); if (empty($values['tenancy'])) { $tenancyService->setTenancy(1); } else { $tenancyService->setTenancy($values['tenancy']); } $criteria = new \Doctrine\Common\Collections\Criteria(); $criteria->andWhere($criteria->expr()->eq("name", $values['name'])); $em = $this->getDoctrine()->getManager(); $repo = $em->getRepository($this->getRepository()); $entities = $repo->matching($criteria)->toArray(); if (count($entities) > 0 && $entities[0]) { // la entidad existe por lo tanto la actualizo $resp = $this->putAction($request, $entities[0]); } else { // la entidad no existe, entonces la creo // deshabilito el auto increment del id $resp = $this->postAction($request); } return $resp; } }