/**
  * (non-PHPdoc)
  * @see PartKeepr\Service.RestfulService::destroy()
  */
 public function destroy()
 {
     $this->requireParameter("id");
     $file = ProjectAttachment::loadById($this->getParameter("id"));
     PartKeepr::getEM()->remove($file);
     PartKeepr::getEM()->flush();
     return array("data" => null);
 }
Exemple #2
0
    $tmpFileId = str_replace("TMP:", "", $id);
    $file = TempUploadedFile::loadById($tmpFileId);
} else {
    try {
        switch ($type) {
            case "PartKeepr.PartAttachment":
            case "PartAttachment":
                $file = PartAttachment::loadById($id);
                break;
            case "FootprintAttachment":
            case "PartKeepr.FootprintAttachment":
                $file = FootprintAttachment::loadById($id);
                break;
            case "ProjectAttachment":
            case "PartKeepr.ProjectAttachment":
                $file = ProjectAttachment::loadById($id);
                break;
            case "Print":
                $file = TempUploadedFile::loadById($id);
                break;
            default:
                $file = null;
                // Add default image?
        }
    } catch (\Exception $e) {
        $file = null;
        // Something bad happened
    }
}
if ($file == null) {
    // Could not find the image, but maybe we want a temporary image?