public function getFileSet()
 {
     $fs = Set::getByName($this->getID());
     return $fs;
 }
 public function upload_files()
 {
     $files = array();
     if ($this->token->validate('upload_files')) {
         $r = $this->entityManager->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\Batch');
         $batch = $r->findOneById($this->request->request('id'));
         if (is_object($batch)) {
             $cf = \Core::make('helper/file');
             $fp = \FilePermissions::getGlobal();
             if (isset($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if (!$fp->canAddFileType($cf->getExtension($_FILES['file']['name']))) {
                     throw new \Exception(Importer::getErrorMessage(Importer::E_FILE_INVALID_EXTENSION));
                 } else {
                     $ih = new Importer();
                     $response = $ih->import($_FILES['file']['tmp_name'], $_FILES['file']['name']);
                     if (!$response instanceof \Concrete\Core\File\Version) {
                         throw new \Exception(Importer::getErrorMessage($response));
                     } else {
                         $file = $response->getFile();
                         $fs = Set::getByName($batch->getID());
                         if (!is_object($fs)) {
                             $fs = Set::createAndGetSet($batch->getID(), Set::TYPE_PRIVATE);
                         }
                         $fs->addFileToSet($file);
                         $files[] = $file;
                     }
                 }
             }
         }
     }
     $this->flash('success', t('File(s) uploaded successfully'));
     $r = new \Concrete\Core\File\EditResponse();
     $r->setFiles($files);
     $r->outputJSON();
 }