/** * @NoAdminRequired * * @param int $sketchId * @param int $id * @return DataResponse */ public function destroy($sketchId, $id) { try { $line = $this->lineMapper->find($sketchId, $id, $this->userId); } catch (Exception $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } $this->lineMapper->delete($line); // Delete related points foreach ($this->pointMapper->findAll($id, $this->userId) as $point) { $this->pointMapper->delete($point); } return new DataResponse($line); }
/** * @param Line $line * @param string $userId */ public function addPoints(Line $line, $userId) { $line->setPoints($this->pointMapper->findAll($line->getId(), $userId)); }