Styled book form and added an ux dropzone component.

This commit is contained in:
krzysiej
2022-05-31 14:34:47 +02:00
parent 040c82831b
commit 9817aa4c3f
14 changed files with 211 additions and 25 deletions

View File

@@ -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()
);
}

View 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);
}
}
}