protected function processForm()
 {
     foreach ($this->form->getValue('containers') as $item) {
         $params = $this->context->routing->parse(Qubit::pathInfo($item));
         $this->resource->addPhysicalObject($params['_sf_route']->resource);
     }
     if (null !== $this->form->getValue('name') || null !== $this->form->getValue('location')) {
         $physicalObject = new QubitPhysicalObject();
         $physicalObject->name = $this->form->getValue('name');
         $physicalObject->location = $this->form->getValue('location');
         $params = $this->context->routing->parse(Qubit::pathInfo($this->form->getValue('type')));
         $physicalObject->type = $params['_sf_route']->resource;
         $physicalObject->save();
         $this->resource->addPhysicalObject($physicalObject);
     }
     if (isset($this->request->delete_relations)) {
         foreach ($this->request->delete_relations as $item) {
             $params = $this->context->routing->parse(Qubit::pathInfo($item));
             $params['_sf_route']->resource->delete();
         }
     }
 }
 public function execute($request)
 {
     $this->resource = $this->getRoute()->resource;
     if (!isset($this->resource)) {
         $this->forward404();
     }
     if (!$this->getUser()->isAuthenticated()) {
         QubitAcl::forwardUnauthorized();
     }
     $criteria = new Criteria();
     $criteria->setDistinct();
     $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_EQUAL);
     $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_EQUAL);
     $criteria->add(QubitRelation::TYPE_ID, QubitTerm::HAS_PHYSICAL_OBJECT_ID);
     $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID);
     $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitPhysicalObject::ID);
     $this->physicalObjects = QubitPhysicalObject::get($criteria);
     if (0 == count($this->physicalObjects)) {
         return sfView::ERROR;
     }
     $c2 = clone $criteria;
     $this->foundcount = BasePeer::doCount($c2)->fetchColumn(0);
 }
 public static function getphysicalObjectsRelatedByparentIdById($id, array $options = array())
 {
     $criteria = new Criteria();
     self::addphysicalObjectsRelatedByparentIdCriteriaById($criteria, $id);
     return QubitPhysicalObject::get($criteria, $options);
 }
 public function setPhysicalObjectByName($physicalObjectName, $options)
 {
     // see if physical object already exists, otherwise create a new physical object
     $criteria = new Criteria();
     $criteria->addJoin(QubitPhysicalObject::ID, QubitPhysicalObjectI18n::ID);
     $criteria->add(QubitPhysicalObjectI18n::NAME, $physicalObjectName);
     if ($existingPhysicalObject = QubitPhysicalObject::getOne($criteria)) {
         $this->addPhysicalObject($existingPhysicalObject);
     } else {
         $newPhysicalObject = new QubitPhysicalObject();
         $newPhysicalObject->setName($physicalObjectName);
         // see if physical object type already exists, otherwise create a new one
         if ($options['type']) {
             $criteria = new Criteria();
             $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID);
             $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PHYSICAL_OBJECT_TYPE_ID);
             $criteria->add(QubitTermI18n::NAME, $options['type']);
             if ($physicalObjectType = QubitTerm::getOne($criteria)) {
                 $newPhysicalObject->setTypeId($physicalObjectType->id);
             } else {
                 $newTerm = new QubitTerm();
                 $newTerm->setTaxonomyId(QubitTaxonomy::PHYSICAL_OBJECT_TYPE_ID);
                 $newTerm->setName($options['type']);
                 $newTerm->parentId = QubitTerm::CONTAINER_ID;
                 $newTerm->save();
                 $newPhysicalObject->setTypeId($newTerm->id);
             }
         }
         if (isset($options['location'])) {
             $newPhysicalObject->setLocation($options['location']);
         }
         $newPhysicalObject->save();
         $this->addPhysicalObject($newPhysicalObject);
     }
 }