Styled book form and added an ux dropzone component.
This commit is contained in:
@@ -44,9 +44,9 @@ class FileController extends AbstractController
|
||||
public function get(File $file)
|
||||
{
|
||||
return $this->file(
|
||||
$filePath = $this->getParameter('book_files') . '/' . 'ebook_' . $file->getBook()->getId() . '_' .
|
||||
md5($file->getFileName()) . '.' .
|
||||
$file->getExtension(),
|
||||
$this->getParameter('book_files') . '/' . 'ebook_' . $file->getBook()->getId() . '_' .
|
||||
md5($file->getFileName()) . '.' .
|
||||
$file->getExtension(),
|
||||
$file->getFileName()
|
||||
);
|
||||
}
|
||||
|
||||
36
src/Service/FileService.php
Normal file
36
src/Service/FileService.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\File;
|
||||
use App\Repository\FileRepository;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class FileService
|
||||
{
|
||||
private Filesystem $fileSystem;
|
||||
private string $bookFiles;
|
||||
|
||||
public function __construct(string $bookFiles, FileSystem $filesystem)
|
||||
{
|
||||
$this->bookFiles = $bookFiles;
|
||||
$this->fileSystem = $filesystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param File[] $files
|
||||
* @return void
|
||||
*/
|
||||
public function removeFiles(Collection $files)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$filePath = $this->bookFiles . '/' . 'ebook_' . $file->getBook()->getId() . '_' .
|
||||
md5($file->getFileName()) . '.' .
|
||||
$file->getExtension();
|
||||
|
||||
$this->fileSystem->remove($filePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user