|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Controller\Backend; |
|
|
namespace Lc\ShopBundle\Controller\Backend; |
|
|
|
|
|
|
|
|
use App\Entity\Product; |
|
|
use App\Entity\Product; |
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; |
|
|
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; |
|
|
|
|
|
use FOS\UserBundle\Model\UserManagerInterface; |
|
|
use Lc\ShopBundle\Context\ImageInterface; |
|
|
use Lc\ShopBundle\Context\ImageInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
use Lc\ShopBundle\Context\ProductCategoryInterface; |
|
|
use Lc\ShopBundle\Context\ProductCategoryInterface; |
|
|
|
|
|
|
|
|
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType; |
|
|
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType; |
|
|
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType; |
|
|
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType; |
|
|
use Lc\ShopBundle\Model\ProductFamily; |
|
|
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\ChoiceType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\NumberType; |
|
|
use Symfony\Component\Form\Extension\Core\Type\NumberType; |
|
|
use Symfony\Component\Form\FormError; |
|
|
use Symfony\Component\Form\FormError; |
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
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 |
|
|
class ProductFamilyController extends AdminController |
|
|
{ |
|
|
{ |
|
|
private $taxRateClass; |
|
|
private $taxRateClass; |
|
|
private $choicesTaxRateParam; |
|
|
private $choicesTaxRateParam; |
|
|
private $choicesSupplierTaxRateParam; |
|
|
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) |
|
|
public function createEntityFormBuilder($entity, $view, $override = true) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
$this->processProducts($newProductFamily, true); |
|
|
$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); |
|
|
$this->em->persist($newProductFamily); |