Browse Source

Merge branch 'develop'

master
Guillaume 4 years ago
parent
commit
68148d82ad
2 changed files with 29 additions and 2 deletions
  1. +21
    -2
      ShopBundle/Controller/Backend/ProductFamilyController.php
  2. +8
    -0
      ShopBundle/Repository/ProductFamilyRepository.php

+ 21
- 2
ShopBundle/Controller/Backend/ProductFamilyController.php View File

@@ -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);

+ 8
- 0
ShopBundle/Repository/ProductFamilyRepository.php View File

@@ -37,6 +37,14 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
return $query->getQuery()->getResult() ;
}

public function findAllOnline()
{
$query = $this->findByMerchantQuery() ;
$query = $this->joinRelations($query) ;
$query->andWhere('e.status = 1') ;
return $query->getQuery()->getResult() ;
}

public function findOneBySlug($slug)
{
$query = $this->findByMerchantQuery() ;

Loading…
Cancel
Save