public function processForm()
 {
     $tmpPath = sfConfig::get('sf_upload_dir') . '/tmp';
     // Upload files
     $i = 0;
     foreach ($this->form->getValue('files') as $file) {
         if (0 == strlen($file['infoObjectTitle'] || 0 == strlen($file['tmpName']))) {
             continue;
         }
         $i++;
         // Create an information object for this digital object
         $informationObject = new QubitInformationObject();
         $informationObject->parentId = $this->resource->id;
         if (0 < strlen($title = $file['infoObjectTitle'])) {
             $informationObject->title = $title;
         }
         if (0 != intval($levelOfDescriptionId = $this->form->getValue('level_of_description_id'))) {
             $informationObject->levelOfDescriptionId = $levelOfDescriptionId;
         }
         $informationObject->setStatus(array('typeId' => QubitTerm::STATUS_TYPE_PUBLICATION_ID, 'statusId' => sfConfig::get('app_defaultPubStatus')));
         // Save description
         $informationObject->save();
         if (file_exists("{$tmpPath}/{$file['tmpName']}")) {
             // Upload asset and create digital object
             $digitalObject = new QubitDigitalObject();
             $digitalObject->informationObject = $informationObject;
             $digitalObject->usageId = QubitTerm::MASTER_ID;
             $digitalObject->assets[] = new QubitAsset($file['name'], file_get_contents("{$tmpPath}/{$file['tmpName']}"));
             $digitalObject->save();
         }
         $thumbnailIsGeneric = (bool) strstr($file['thumb'], 'generic-icons');
         // Clean up temp files
         if (file_exists("{$tmpPath}/{$file['tmpName']}")) {
             unlink("{$tmpPath}/{$file['tmpName']}");
         }
         if (!$thumbnailIsGeneric && file_exists("{$tmpPath}/{$file['thumb']}")) {
             unlink("{$tmpPath}/{$file['thumb']}");
         }
     }
     $this->redirect(array($this->resource, 'module' => 'informationobject'));
 }
 /**
  * Wrapper for QubitDigitalObject::importFromUri() method
  *
  * @param array $uris URIs of remote files
  * @return QubitInformationObject $this
  *
  * @TODO allow for different usage types
  */
 public function importDigitalObjectFromUri($uris)
 {
     if (is_array($uris) && 1 < count($uris)) {
         // Get publication status from current object
         $pubStatus = null;
         if (isset($this->statuss) && 0 < count($this->statuss)) {
             foreach ($this->statuss as $status) {
                 if (QubitTerm::STATUS_TYPE_PUBLICATION_ID == $status->typeId) {
                     $pubStatus = $status->statusId;
                     break;
                 }
             }
         }
         foreach ($uris as $uri) {
             $infoObject = new QubitInformationObject();
             $digitalObject = new QubitDigitalObject();
             $digitalObject->usageId = QubitTerm::MASTER_ID;
             $digitalObject->importFromUri($uri);
             $infoObject->digitalObjects[] = $digitalObject;
             $infoObject->title = $digitalObject->name;
             if (isset($pubStatus)) {
                 $infoObject->setStatus(array('typeId' => QubitTerm::STATUS_TYPE_PUBLICATION_ID, 'statusId' => $pubStatus));
             }
             $this->informationObjectsRelatedByparentId[] = $infoObject;
         }
     } else {
         $digitalObject = new QubitDigitalObject();
         $digitalObject->usageId = QubitTerm::MASTER_ID;
         if (is_array($uris)) {
             $uris = array_shift($uris);
         }
         $digitalObject->importFromUri($uris);
         $this->digitalObjects[] = $digitalObject;
     }
     return $this;
 }