Преглед на файлове

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…
Отказ
Запис