src/Controller/Super/BatchCollegeAttachmentController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Super;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Vich\UploaderBundle\Handler\DownloadHandler;
  7. use App\Entity\Batch;
  8. use App\Repository\BatchCollegeAttachmentRepository;
  9. use App\Form\BatchCollegeAttachmentSearchType;
  10. use App\Entity\BatchCollegeAttachment;
  11. /**
  12.  *
  13.  * @Route("/super/batch-college-attachment/", name="super_batch_college_attachment_")
  14.  * @author "wendell.zheng <wxzheng@ustc.edu.cn>"
  15.  */
  16. class BatchCollegeAttachmentController extends BaseController
  17. {
  18.     /**
  19.      *
  20.      * @Route("list/{id}", name="list", requirements={"id"="\d+"})
  21.      */
  22.     public function list(Batch $batchRequest $requestBatchCollegeAttachmentRepository $repository): Response
  23.     {
  24.         $form $this->createForm(BatchCollegeAttachmentSearchType::class, null, [
  25.             'batch' => $batch
  26.         ]);
  27.         $parameters = [
  28.             'batch' => $batch
  29.         ];
  30.         return $this->render('super/batch_college_attachment/list.html.twig', [
  31.             'title' => $batch->getName(),
  32.             'name' => $this->getLowerName(),
  33.             'batch' => $batch,
  34.             'entities' => $repository->search($parameters),
  35.             'form' => $form->createView()
  36.         ]);
  37.     }
  38.     /**
  39.      *
  40.      * @Route("download/{id}", name="download", requirements={"id"="\d+"})
  41.      */
  42.     public function download(BatchCollegeAttachment $attachmentDownloadHandler $downloadHandler): Response
  43.     {
  44.         $name $attachment->getCollege()->getName() . '_' $attachment->getDownloadName();
  45.         return $downloadHandler->downloadObject($attachment'attachment'null$name);
  46.     }
  47. }