소스 검색

Backend : téléchargement de documents

feature/export_comptable
Guillaume 4 년 전
부모
커밋
b4ecb7d4a3
1개의 변경된 파일45개의 추가작업 그리고 0개의 파일을 삭제
  1. +45
    -0
      ShopBundle/Controller/Backend/DocumentController.php

+ 45
- 0
ShopBundle/Controller/Backend/DocumentController.php 파일 보기

@@ -0,0 +1,45 @@
<?php

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Services\Utils;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;

class DocumentController extends AdminController
{
protected $documentRepository ;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator)
{
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport, $orderUtils, $translator);
$this->documentRepository = $this->em->getRepository($this->em->getClassMetadata(DocumentInterface::class)->getName()) ;
}

public function downloadInvoiceAction()
{
$idDocument = $this->request->get('id') ;
$document = $this->documentRepository->find($idDocument) ;

$orderShop = null ;
if($document) {
$orderShops = $document->getOrderShops() ;
$orderShop = (isset($orderShops[0])) ? $orderShops[0] : null ;
}

if($document && $orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
}
else {
throw new NotFoundHttpException('Document introuvable') ;
}
}

}

Loading…
취소
저장