public function persist($entity) { try { if ($entity->isNew()) { $id = $this->db->insertEntity($this->table, $entity); if ($id == 0) { throw new RepoException("Failed to persist entity."); } } else { $id = $entity->getId(); if (!$this->db->updateEntity($this->table, $entity)) { throw new RepoException("Failed to persist entity."); } } return $this->find($id); } catch (\Exception $e) { $this->logger->logException($e); return false; } }