```
✨ feat(ShareController): Ajoute le contrôleur de partage de fichiers et modifie les routes.
```
This commit is contained in:
41
src/Controller/Artemis/ShareController.php
Normal file
41
src/Controller/Artemis/ShareController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Artemis;
|
||||
|
||||
use App\Entity\Account;
|
||||
use App\Entity\AccountResetPasswordRequest;
|
||||
use App\Entity\TempFile;
|
||||
use App\Form\RequestPasswordConfirmType;
|
||||
use App\Form\RequestPasswordRequestType;
|
||||
use App\Repository\EsyWebTutoRepository;
|
||||
use App\Service\Mailer\Mailer;
|
||||
use App\Service\ResetPassword\Event\ResetPasswordConfirmEvent;
|
||||
use App\Service\ResetPassword\Event\ResetPasswordEvent;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||
use Twig\Environment;
|
||||
use Vich\UploaderBundle\Handler\DownloadHandler;
|
||||
|
||||
class ShareController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/partage/{id}',name: 'share',methods: ['GET'])]
|
||||
public function share(?TempFile $tempFile,DownloadHandler $downloadHandler): Response
|
||||
{
|
||||
if(!$tempFile instanceof TempFile) {
|
||||
return new JsonResponse([
|
||||
"Le fichier n'est plus disponible"
|
||||
]);
|
||||
}
|
||||
return $downloadHandler->downloadObject($tempFile,"share");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class ShareController extends AbstractController
|
||||
writer: new PngWriter(),
|
||||
writerOptions: [],
|
||||
validateResult: false,
|
||||
data: $baseUrl.$uploaderHelper->asset($tempFile,"share"),
|
||||
data: $baseUrl."/partage/".$tempFile->getId(),
|
||||
encoding: new Encoding('UTF-8'),
|
||||
errorCorrectionLevel: ErrorCorrectionLevel::High,
|
||||
size: 150,
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
<div class="mt-2 text-center">
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mb-4">Scannez pour accéder au fichier</p>
|
||||
<img src="{{ path('artemis_tools_share_qrcode', {'id': file.id}) }}" alt="QR Code du fichier {{ file.name }}" class="zc mx-auto border dark:border-gray-700 p-2 w-40 h-40 object-contain">
|
||||
<p class="mt-3 text-xs text-gray-400 dark:text-gray-500 truncate">{{ url('artemis_tools_share_view', {'id': file.id}) }}</p>
|
||||
<p class="mt-3 text-xs text-gray-400 dark:text-gray-500 truncate">{{ url('share', {'id': file.id}) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user