Exemplo 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();
 }
Exemplo n.º 2
0
 /**
  * Creates a node structure for the given path
  * 
  * @param $path array The components of the path
  * @param $node Node  The parent node
  */
 public function addFootprintPath(array $path, $node)
 {
     if (count($path) == 0) {
         return $node;
     }
     $name = array_shift($path);
     $childNode = null;
     foreach ($node->getChildren() as $child) {
         if ($child->getNode()->getName() == $name) {
             $childNode = $child;
         }
     }
     if ($childNode === null) {
         $category = new FootprintCategory();
         $category->setParent($node->getNode()->getId());
         $category->setName($name);
         $childNode = FootprintCategoryManager::getInstance()->addCategory($category);
     }
     return $this->addFootprintPath($path, $childNode);
 }
Exemplo n.º 3
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;
         }
     }
 }