/**
  * @see BackendAdapter::updateFile
  */
 public function updateFile(File $file)
 {
     $sql = "\n        UPDATE xi_filelib_file\n        SET folder_id = :folderId, fileprofile = :profile, filename = :name, date_created = :dateCreated,\n        status = :status,uuid = :uuid, resource_id = :resourceId, data = :data\n        WHERE id = :id\n        ";
     $stmt = $this->conn->prepare($sql);
     $stmt->execute(array('folderId' => $file->getFolderId(), 'profile' => $file->getProfile(), 'name' => $file->getName(), 'dateCreated' => $file->getDateCreated()->format('Y-m-d H:i:s'), 'status' => $file->getStatus(), 'uuid' => $file->getUuid(), 'resourceId' => $file->getResource()->getId(), 'data' => json_encode($file->getdata()->toArray()), 'id' => $file->getId()));
     return (bool) $stmt->rowCount();
 }
Example #2
0
 /**
  * Returns a link for a file
  *
  * @param  File   $file
  * @return string Link
  */
 protected function getBaseLink(File $file)
 {
     $folder = $this->folderRepository->find($file->getFolderId());
     $beautifurl = explode('/', $folder->getUrl());
     $beautifurl = array_filter($beautifurl, function ($beautifurl) {
         return (bool) $beautifurl;
     });
     $beautifurl = array_map(function ($fragment) {
         return $this->slugifier->slugify($fragment);
     }, $beautifurl);
     $beautifurl[] = $file->getName();
     $beautifurl = implode(DIRECTORY_SEPARATOR, $beautifurl);
     return $beautifurl;
 }
 /**
  * Returns a file's folder
  *
  * @param  File   $file
  * @return Folder
  */
 private function getFilesFolder(File $file)
 {
     return $this->folderRepository->find($file->getFolderId());
 }
Example #4
0
 /**
  * Updates a file
  *
  * @param  File             $file
  * @throws FilelibException If file could not be updated.
  */
 public function updateFile(File $file)
 {
     if (!$this->findById($file->getFolderId(), 'Xi\\Filelib\\Folder\\Folder')) {
         throw new FolderNotFoundException(sprintf('Folder was not found with id "%s"', $file->getFolderId()));
     }
     $this->resolveAdapter()->updateFile($file);
 }