public function UploadFiles()
 {
     $this->uploadDirectory = $this->GetUploadDirectory();
     $this->resultJson["fileUploadResults"] = array();
     foreach ($this->files as $file) {
         $this->currentFile = new \Library\Core\BO\FileUploadResult($file["tmp_name"]);
         //Init object
         $document = $this->InitDocumentObject();
         //Check if file exist before adding a row in DB
         $this->currentFile->setFilePath($this->uploadDirectory . "/" . $document->document_value());
         \Library\Core\DirectoryManager::CreateDirectory($this->uploadDirectory);
         $fileExists = \Library\Core\DirectoryManager::FileExists($this->currentFile->filePath());
         $this->currentFile->setDoesExist($fileExists);
         //Add document to DB
         if (!$fileExists) {
             //Don't add the document in DB if already added
             $this->AddDocumentToDatabase($document);
             //Add document to uploads directory
             $uploaded = $this->UploadAFile($this->currentFile->tmpFilePath(), $this->currentFile->filePath());
             $this->currentFile->setIsUploaded($uploaded);
         } else {
             $this->currentFile->setIsUploaded(false);
         }
         array_push($this->resultJson["fileUploadResults"], $this->currentFile);
     }
     return $this->resultJson;
 }
 function LoadFiles()
 {
     $this->uploadDirectory = $this->GetUploadDirectory();
     $this->resultJson["fileResults"] = array();
     $documents = $this->LoadDocumentObjects();
     foreach ($documents as &$document) {
         $this->currentFile = new \Library\Core\BO\FileUploadResult($document->document_value());
         $this->currentFile->setFilePath($this->uploadDirectory . "/" . $document->document_value());
         $this->currentFile->setWebPath($this->GetWebUploadDirectory() . "/" . $document->document_value());
         $fileExists = \Library\Core\DirectoryManager::FileExists($this->currentFile->filePath());
         if ($fileExists) {
             $this->currentFile->setDoesExist(true);
             array_push($this->resultJson["fileResults"], $this->currentFile);
         }
     }
     return $this->resultJson;
 }
 public function __construct(\Library\Application $app)
 {
     parent::__construct($app);
     $this->files = \Library\Core\DirectoryManager::GetFilesNamesRecursively(__ROOT__ . \Library\Enums\ApplicationFolderName::WebJs, "js");
 }
 protected function AddFilePathToObjectList($list)
 {
     if (is_array($list)) {
         foreach ($list as &$object) {
             if ($object instanceof \Library\Interfaces\IDocument) {
                 $filePath = $this->GetUploadDirectory($object) . "/" . $object->Filename();
                 $fileExists = \Library\Core\DirectoryManager::FileExists($filePath);
                 if ($fileExists) {
                     $object->setWebPath($this->GetWebUploadDirectory($object) . "/" . $object->Filename());
                 }
             }
         }
     }
     return $list;
 }