Ejemplo n.º 1
0
 public function moveFootprint()
 {
     $this->requireParameter("targetCategory");
     $this->requireParameter("id");
     $footprint = Footprint::loadById($this->getParameter("id"));
     $category = FootprintCategory::loadById($this->getParameter("targetCategory"));
     $footprint->setCategory($category);
     PartKeepr::getEM()->flush();
 }
Ejemplo n.º 2
0
 /**
  * Deserializes the footprint
  * @param array $parameters The array with the parameters to set
  */
 public function deserialize(array $parameters)
 {
     foreach ($parameters as $key => $value) {
         switch ($key) {
             case "name":
                 $this->setName($value);
                 break;
             case "description":
                 $this->setDescription($value);
                 break;
             case "image_id":
                 if ($value == "") {
                     echo "/** Breaking because of empty value */";
                     break;
                 }
                 try {
                     $image = FootprintImage::loadById($value);
                     $this->setImage($image);
                 } catch (\Exception $e) {
                     if ($this->getImage()) {
                         // Image was not found, maybe a temporary image?
                         $this->getImage()->replaceFromTemporaryFile($value);
                     } else {
                         $image = FootprintImage::createFromTemporaryFile($value);
                         $this->setImage($image);
                     }
                 }
                 break;
             case "category":
                 try {
                     $category = FootprintCategory::loadById($value);
                     $this->setCategory($category);
                 } catch (\Exception $e) {
                     // Category was not found, do not change category.
                 }
                 break;
             case "attachments":
                 $this->deserializeChildren($value, $this->getAttachments(), "PartKeepr\\Footprint\\FootprintAttachment");
                 foreach ($this->getAttachments() as $attachment) {
                     $attachment->setFootprint($this);
                 }
                 break;
         }
     }
 }