Controller/TicketAttachmentController.php
public function downloadAction($ticketMessageId)
    {
        $ticketManager = $this->get('hackzilla_ticket.ticket_manager');
        $ticketMessage = $ticketManager->getMessageById($ticketMessageId);

        if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
            throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
        }

        // check permissions
        $userManager = $this->get('hackzilla_ticket.user_manager');
        $userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());

        $downloadHandler = $this->get('vich_uploader.download_handler');

        return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
    }
public function downloadAction($ticketMessageId)
    {
        $ticketManager = $this->get('hackzilla_ticket.ticket_manager');
        $ticketMessage = $ticketManager->getMessageById($ticketMessageId);

        if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
            throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
        }

        // check permissions
        $userManager = $this->get('hackzilla_ticket.user_manager');
        $userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());

        $downloadHandler = $this->get('vich_uploader.download_handler');

        return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
    }
public function downloadAction ( $ ticketMessageId ) { $ ticketManager = $ this -> get ( 'hackzilla_ticket.ticket_manager' ) ; $ ticketMessage = $ ticketManager -> getMessageById ( $ ticketMessageId ) ; if ( ! $ ticketMessage || ! $ ticketMessage instanceof TicketMessageWithAttachment ) { throw $ this -> createNotFoundException ( $ this -> get ( 'translator' ) -> trans ( 'ERROR_FIND_TICKET_ENTITY' , [ ] , 'HackzillaTicketBundle' ) ) ; } // check permissions $ userManager = $ this -> get ( 'hackzilla_ticket.user_manager' ) ; $ userManager -> hasPermission ( $ userManager -> getCurrentUser ( ) , $ ticketMessage -> getTicket ( ) ) ; $ downloadHandler = $ this -> get ( 'vich_uploader.download_handler' ) ; return $ downloadHandler -> downloadObject ( $ ticketMessage , 'attachmentFile' ) ; }
Download attachment on message.

@param int $ticketMessageId

@return \Symfony\Component\HttpFoundation\Response
Download attachment on message .