Ver código fonte

Merge branch 'develop'

master
Guillaume 4 anos atrás
pai
commit
68148d82ad
2 arquivos alterados com 29 adições e 2 exclusões
  1. +21
    -2
      ShopBundle/Controller/Backend/ProductFamilyController.php
  2. +8
    -0
      ShopBundle/Repository/ProductFamilyRepository.php

+ 21
- 2
ShopBundle/Controller/Backend/ProductFamilyController.php Ver arquivo

@@ -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 Ver arquivo

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

Carregando…
Cancelar
Salvar