public function destroy()
 {
     $this->requireParameter("id");
     $logo = ManufacturerICLogo::loadById($this->getParameter("id"));
     PartKeepr::getEM()->remove($logo);
     PartKeepr::getEM()->flush();
     return array("data" => null);
 }
Exemple #2
0
use PartKeepr\Part\PartAttachment;
use PartKeepr\Image\ImageRenderer;
use PartKeepr\Part\PartImage, PartKeepr\StorageLocation\StorageLocationImage, PartKeepr\Footprint\FootprintImage, PartKeepr\TempImage\TempImage, PartKeepr\PartKeepr, PartKeepr\Image\Image, PartKeepr\Image\CachedImage, PartKeepr\Manufacturer\ManufacturerICLogo;
include "../src/backend/PartKeepr/PartKeepr.php";
PartKeepr::initialize("");
$type = $_REQUEST["type"];
$id = $_REQUEST["id"];
if (substr($id, 0, 4) === "TMP:") {
    $tmpImageId = str_replace("TMP:", "", $id);
    $image = TempImage::loadById($tmpImageId);
} else {
    try {
        switch ($type) {
            case Image::IMAGE_ICLOGO:
                $image = ManufacturerICLogo::loadById($id);
                break;
            case Image::IMAGE_FOOTPRINT:
                $image = FootprintImage::loadById($id);
                break;
            case Image::IMAGE_STORAGELOCATION:
                $image = StorageLocationImage::loadById($id);
                break;
            case "partattachment":
                $attachment = PartAttachment::loadById($id);
                $image = new PartImage();
                $image->replace($attachment->getFilename());
                break;
            default:
                $image = null;
                // Add default image?