/** * (non-PHPdoc) * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() */ public function create () { $this->requireParameter("tmp_id"); $this->requireParameter("manufacturer_id"); $tmpImage = TempImage::loadById($this->getParameter("tmp_id")); $image = new ManufacturerICLogo(); $manufacturer = Manufacturer::loadById($this->getParameter("manufacturer_id")); $image->setManufacturer($manufacturer); $image->replace($tmpImage->getFilename()); $image->setOriginalFilename($tmpImage->getOriginalFilename()); PartKeepr::getEM()->persist($image); PartKeepr::getEM()->flush(); return $image->serialize(); }
$image = PartImage::loadById($id); break; default: $image = null; // Add default image? } } catch (\Exception $e) { $image = null; // Something bad happened } if ($image == null) { // Could not find the image, but maybe we want a temporary image? if (array_key_exists("tmpId", $_REQUEST)) { $image = TempImage::loadById($_REQUEST["tmpId"]); } if ($image === null) { /* The image is still null - output an "image not found" image. */ $image = imagecreate($_REQUEST["w"], $_REQUEST["h"]); $white = imagecolorallocate($image, 255,255,255); $black = imagecolorallocate($image, 0,0,0); header("Content-Type: image/png"); $w = $_REQUEST["w"]-1; $h = $_REQUEST["h"]-1; imagefill($image, 0,0, $white); /* Draw the X */