public function RenderAction(\SW\DocManagerBundle\Entity\Document $document) { $path = $document->getPath(); $response = new BinaryFileResponse($path); $response->trustXSendfileTypeHeader(); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $document->getName()); return $response; }
private function buildUploadSession(Document $document) { $repositoryUploadSession = $this->getRepository("SWDocManagerBundle:UploadSession"); $repositoryUser = $this->getRepository('SWDocManagerBundle:User'); $user = $repositoryUser->findByLastname('Manikon')[0]; $document->setInitials($user->getInitial()); $document->setCreator($user); $document->setNameAlreadyUsed(false); $uploadSession = $repositoryUploadSession->findOneByDocumentRef($document); if ($uploadSession == null) { $uploadSession = new UploadSession(); $uploadSession->getDocuments()->add($document); $uploadSession->setDocumentRef($document); } return $uploadSession; }
/** * Add document * * @param \SW\DocManagerBundle\Entity\Document $document * * @return UploadSession */ public function addDocument(\SW\DocManagerBundle\Entity\Document $document) { $this->documents[] = $document; $document->setUploadSession($this); return $this; }
protected function renameFile(Document $document, $newname) { $file = new File($document->getPath()); if (null === $file) { return; } $file->move($this->getUploadRootDir(), $newname); $document->setName($newname); $document->setPath($this->getUploadRootDir() . '/' . $newname); return $document; }