<?php
namespace App\Controller\Super;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Vich\UploaderBundle\Handler\DownloadHandler;
use App\Entity\Batch;
use App\Repository\BatchCollegeAttachmentRepository;
use App\Form\BatchCollegeAttachmentSearchType;
use App\Entity\BatchCollegeAttachment;
/**
*
* @Route("/super/batch-college-attachment/", name="super_batch_college_attachment_")
* @author "wendell.zheng <wxzheng@ustc.edu.cn>"
*/
class BatchCollegeAttachmentController extends BaseController
{
/**
*
* @Route("list/{id}", name="list", requirements={"id"="\d+"})
*/
public function list(Batch $batch, Request $request, BatchCollegeAttachmentRepository $repository): Response
{
$form = $this->createForm(BatchCollegeAttachmentSearchType::class, null, [
'batch' => $batch
]);
$parameters = [
'batch' => $batch
];
return $this->render('super/batch_college_attachment/list.html.twig', [
'title' => $batch->getName(),
'name' => $this->getLowerName(),
'batch' => $batch,
'entities' => $repository->search($parameters),
'form' => $form->createView()
]);
}
/**
*
* @Route("download/{id}", name="download", requirements={"id"="\d+"})
*/
public function download(BatchCollegeAttachment $attachment, DownloadHandler $downloadHandler): Response
{
$name = $attachment->getCollege()->getName() . '_' . $attachment->getDownloadName();
return $downloadHandler->downloadObject($attachment, 'attachment', null, $name);
}
}