Procházet zdrojové kódy

[Backend] Produits : correctif bug duplication produits

feature/export_comptable
Guillaume před 4 roky
rodič
revize
9b6aa189b6
1 změnil soubory, kde provedl 21 přidání a 2 odebrání
  1. +21
    -2
      ShopBundle/Controller/Backend/ProductFamilyController.php

+ 21
- 2
ShopBundle/Controller/Backend/ProductFamilyController.php Zobrazit soubor

@@ -3,7 +3,9 @@
namespace Lc\ShopBundle\Controller\Backend;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\ImageInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
@@ -13,18 +15,32 @@ use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType;
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType;
use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class ProductFamilyController extends AdminController
{
private $taxRateClass;
private $choicesTaxRateParam;
private $choicesSupplierTaxRateParam;
private $parameterBag ;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em,
MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator,
ParameterBagInterface $parameterBag)
{
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator);
$this->parameterBag = $parameterBag ;
}

public function createEntityFormBuilder($entity, $view, $override = true)
{
@@ -408,8 +424,11 @@ class ProductFamilyController extends AdminController
$this->processProducts($newProductFamily, true);
}

if($newProductFamily instanceof ImageInterface){
$newProductFamily->setImage(null);
if($newProductFamily instanceof ImageInterface) {
$basePath = $this->parameterBag->get('kernel.project_dir').'/public/uploads/images/' ;
$imageProductFamily = 'produits/'.md5(time()).'.jpg' ;
copy($basePath.$entity->getImage(), $basePath.$imageProductFamily) ;
$newProductFamily->setImage($imageProductFamily);
}

$this->em->persist($newProductFamily);

Načítá se…
Zrušit
Uložit