/**
  * (non-PHPdoc)
  * @see PartKeepr\Service.RestfulService::destroy()
  */
 public function destroy()
 {
     $this->requireParameter("id");
     $file = FootprintAttachment::loadById($this->getParameter("id"));
     PartKeepr::getEM()->remove($file);
     PartKeepr::getEM()->flush();
     return array("data" => null);
 }
Пример #2
0
PartKeepr::initialize("");
$type = $_REQUEST["type"];
$id = $_REQUEST["id"];
if (substr($id, 0, 4) === "TMP:") {
    $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