Ver código fonte

Merge branch 'develop'

master
Fab 4 anos atrás
pai
commit
db065cdc0d
23 arquivos alterados com 243 adições e 77 exclusões
  1. +8
    -0
      ShopBundle/Context/DocumentUtilsInterface.php
  2. +1
    -3
      ShopBundle/Controller/Backend/AdminController.php
  3. +5
    -1
      ShopBundle/Controller/Backend/DocumentController.php
  4. +1
    -0
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  5. +1
    -1
      ShopBundle/Form/Backend/Common/AddressType.php
  6. +54
    -0
      ShopBundle/Form/Backend/User/TicketTypesNotificationType.php
  7. +2
    -0
      ShopBundle/Model/Document.php
  8. +1
    -1
      ShopBundle/Model/SluggableTrait.php
  9. +20
    -0
      ShopBundle/Model/User.php
  10. +1
    -0
      ShopBundle/Repository/OrderShopRepository.php
  11. +11
    -1
      ShopBundle/Repository/UserRepository.php
  12. +9
    -1
      ShopBundle/Resources/translations/lcshop.fr.yaml
  13. +9
    -3
      ShopBundle/Resources/views/backend/default/block/form_address.html.twig
  14. +15
    -12
      ShopBundle/Resources/views/backend/merchant/panel_delivery.html.twig
  15. +3
    -0
      ShopBundle/Resources/views/backend/merchant/panel_email.html.twig
  16. +11
    -4
      ShopBundle/Services/CsvGenerator.php
  17. +5
    -3
      ShopBundle/Services/DocumentUtils.php
  18. +1
    -1
      ShopBundle/Services/MailUtils.php
  19. +39
    -42
      ShopBundle/Services/Price/PriceUtils.php
  20. +33
    -1
      ShopBundle/Services/TicketUtils.php
  21. +3
    -2
      ShopBundle/Services/UtilsManager.php
  22. +5
    -0
      ShopBundle/Services/UtilsProcess.php
  23. +5
    -1
      ShopBundle/Twig/FrontendTwigExtension.php

+ 8
- 0
ShopBundle/Context/DocumentUtilsInterface.php Ver arquivo

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface DocumentUtilsInterface
{

}

+ 1
- 3
ShopBundle/Controller/Backend/AdminController.php Ver arquivo

@@ -61,10 +61,8 @@ class AdminController extends EasyAdminController
$this->translator = $translator;
}

public function createCustomForm($class, $action, $parameters, $data = true)
public function createCustomForm($class, $action, $parameters, $data = true, $options = array())
{

$options = array();
if ($data) $options['data'] = $parameters['entity'];
$options['action'] = $this->generateUrl('easyadmin', array(
'action' => $action,

+ 5
- 1
ShopBundle/Controller/Backend/DocumentController.php Ver arquivo

@@ -10,6 +10,8 @@ use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -36,7 +38,9 @@ class DocumentController extends AdminController
}

if($document && $orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
return new StreamedResponse(function () use ($orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
});
}
else {
throw new NotFoundHttpException('Document introuvable') ;

+ 1
- 0
ShopBundle/EventSubscriber/EditEventSubscriber.php Ver arquivo

@@ -57,6 +57,7 @@ class EditEventSubscriber implements EventSubscriberInterface

public function updateCommonProperty(GenericEvent $event)
{

/* $this->setUpdated($entity);
$this->setAddressCreatedBy($entity) ;*/
}

+ 1
- 1
ShopBundle/Form/Backend/Common/AddressType.php Ver arquivo

@@ -48,9 +48,9 @@ class AddressType extends AbstractType
])
->add('lastname', TextType::class, ['required' => false])
->add('firstname', TextType::class, ['required' => false])
->add('address', TextareaType::class)
->add('zip', TextType::class)
->add('city', TextType::class)
->add('address', TextType::class)
->add('phone', CollectionType::class, [
'allow_add'=>true,
'allow_delete'=>true,

+ 54
- 0
ShopBundle/Form/Backend/User/TicketTypesNotificationType.php Ver arquivo

@@ -0,0 +1,54 @@
<?php

namespace Lc\ShopBundle\Form\Backend\User;

use App\Entity\Supplier;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Model\Ticket;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TicketTypesNotificationType extends AbstractType
{
protected $em;

public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('ticketTypesNotification', ChoiceType::class, [
'choices'=> array(
'field.Ticket.typeOptions.'.Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION,
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_ERROR=> Ticket::TYPE_PRODUCT_ERROR ,
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_UNAVAILABLE => Ticket::TYPE_PRODUCT_UNAVAILABLE,
'field.Ticket.typeOptions.'.Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM
),
'required' => false,
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop',
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// 'translation_domain' => 'lcshop',
]);
}
}

+ 2
- 0
ShopBundle/Model/Document.php Ver arquivo

@@ -73,9 +73,11 @@ abstract class Document extends AbstractDocumentEntity implements FilterMerchant

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
* @ORM\JoinColumn(nullable=true)
*/
protected $orderShops;


/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
*/

+ 1
- 1
ShopBundle/Model/SluggableTrait.php Ver arquivo

@@ -17,7 +17,7 @@ trait SluggableTrait
return $this->slug;
}

public function setSlug(string $slug): self
public function setSlug(?string $slug): self
{
$this->slug = $slug;


+ 20
- 0
ShopBundle/Model/User.php Ver arquivo

@@ -102,6 +102,13 @@ abstract class User extends UserModelFOS
*/
protected $updatedAt;

/**
* @ORM\Column(type="array", nullable=true)
*/
protected $ticketTypesNotification = [];



public function __construct()
{
parent::__construct();
@@ -433,4 +440,17 @@ abstract class User extends UserModelFOS

return $this;
}


public function getTicketTypesNotification(): ?array
{
return $this->ticketTypesNotification;
}

public function setTicketTypesNotification(?array $ticketTypesNotification): self
{
$this->ticketTypesNotification = $ticketTypesNotification;

return $this;
}
}

+ 1
- 0
ShopBundle/Repository/OrderShopRepository.php Ver arquivo

@@ -300,6 +300,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
$query->select('SUM(orderProduct.quantityOrder) as quantity');

$result = $query->getQuery()->getOneOrNullResult();

return $result['quantity'];

}

+ 11
- 1
ShopBundle/Repository/UserRepository.php Ver arquivo

@@ -32,7 +32,6 @@ class UserRepository extends BaseRepository implements DefaultRepositoryInterfac
return $this->createQueryBuilder('e')
->where(':newsletter MEMBER OF e.newsletters')
->setParameter('newsletter', $newsletter->getId())
->andWhere('e.enabled = 1')
->innerJoin('e.userMerchants', 'um')
->andWhere('um.merchant = :merchant AND um.active = 1')
->setParameter('merchant', $newsletter->getMerchant())
@@ -49,4 +48,15 @@ class UserRepository extends BaseRepository implements DefaultRepositoryInterfac
return $qb->getQuery()->getResult();
}

public function findByTicketTypesNotification($ticketType){

$qb = $this->createQueryBuilder('u')
->where('u.ticketTypesNotification LIKE :ticketType')
->setParameter('ticketType', '%"' . $ticketType . '"%');


return $qb->getQuery()->getResult();

}

}

+ 9
- 1
ShopBundle/Resources/translations/lcshop.fr.yaml Ver arquivo

@@ -21,6 +21,8 @@ group:
default: Édition
Général: Général
Adresse: Adresse
Supplier:
contact: Personne de contact
Reminder:
title: Pense bête
list: Pense bêtes
@@ -265,6 +267,7 @@ field:
emailFromName: "Email (From) : nom"
emailSubjectPrefix: "Email : préfixe"
emailContact: Email (contact)
emailFromPurchaseOrder: "Email (From) : bons de commande"
order: Commande
subject: Sujet
metaTitle: Meta title
@@ -278,6 +281,11 @@ field:
codeHelp: Code utilisé pour retrouver l'ambassade dans le tunnel de commande (Non sensible à la casse)
Supplier:
user: Utilisateur lié
contactName: Personne de contact (Nom et prénom)
contactPhone: Téléphone
contactEmail: Email de la personne de contact
displayTotalWeightInPurchaseOrder: Afficher le poids total dans les bons de commande

ProductFamily:
taxRateInherited: Utiliser la TVA par défaut
activeProducts: Activer les déclinaisons
@@ -406,7 +414,7 @@ field:
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
redeliverySupplierShort: Erreur producteur
redeliverySupplier: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander)
redeliverySupplierMistake: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander)
redeliverySupplierOrderShort: À recommander au producteur
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur)
deliveryType: Type de livraison

+ 9
- 3
ShopBundle/Resources/views/backend/default/block/form_address.html.twig Ver arquivo

@@ -21,15 +21,15 @@
<div class="col-6">
{{ form_row(form.firstname) }}
</div>
<div class="col-12">
{{ form_row(form.address) }}
</div>
<div class="col-6">
{{ form_row(form.zip) }}
</div>
<div class="col-6">
{{ form_row(form.city) }}
</div>
<div class="col-12">
{{ form_row(form.address) }}
</div>
<div class="col-12">
{{ form_row(form.phone) }}
</div>
@@ -57,6 +57,12 @@
<div class="col-6">
{{ form_row(form.longitude) }}
</div>
<div class="col-6">
{{ form_row(form.latitudeOverride) }}
</div>
<div class="col-6">
{{ form_row(form.longitudeOverride) }}
</div>

{{ form_row(form.country) }}


+ 15
- 12
ShopBundle/Resources/views/backend/merchant/panel_delivery.html.twig Ver arquivo

@@ -5,21 +5,24 @@
<div class="row">
<div class="col-8">
{{ macros.card_start('Merchant.delivery','light') }}
<div class="col-12">
{{ form_row(form.merchantConfigs['image-zones']) }}
</div>
<div class="col-12">
{{ form_row(form.merchantConfigs['downtime-per-customer']) }}
</div>
{% if form.merchantConfigs['image-zones'] is defined %}
<div class="col-12">
{{ form_row(form.merchantConfigs['image-zones']) }}
</div>
{% endif %}
{% if form.merchantConfigs['downtime-per-customer'] is defined %}
<div class="col-12">
{{ form_row(form.merchantConfigs['downtime-per-customer']) }}
</div>
{% endif %}
<div class="col-12">
{{ form_row(form.deliveryTaxRate) }}
</div>
<div class="col-12">
{{ form_row(form.merchantConfigs['bike-delivery']) }}
</div>
<div class="col-12">
{{ form_row(form.merchantConfigs['bike-delivery-url-map']) }}
</div>
{% if form.merchantConfigs['bike-delivery-url-map'] is defined %}
<div class="col-12">
{{ form_row(form.merchantConfigs['bike-delivery-url-map']) }}
</div>
{% endif %}
{{ macros.card_end() }}
</div>
</div>

+ 3
- 0
ShopBundle/Resources/views/backend/merchant/panel_email.html.twig Ver arquivo

@@ -18,6 +18,9 @@
<div class="col-12">
{{ form_row(form.merchantConfigs['email-contact']) }}
</div>
<div class="col-12">
{{ form_row(form.merchantConfigs['email-from-purchase-order']) }}
</div>
{{ macros.card_end() }}
</div>
</div>

+ 11
- 4
ShopBundle/Services/CsvGenerator.php Ver arquivo

@@ -29,7 +29,7 @@ class CsvGenerator
protected $convertEncoding ;
protected $fromEncoding ;
protected $toEncoding ;
protected $delimiter ;

public function __construct()
{
@@ -38,6 +38,7 @@ class CsvGenerator
$this->convertEncoding = false ;
$this->fromEncoding = 'UTF-8' ;
$this->toEncoding = 'ISO-8859-1' ;
$this->delimiter = ';' ;
}

public function enableConvertEncoding($toEncoding, $fromEncoding = null)
@@ -53,7 +54,10 @@ class CsvGenerator
public function encode($value)
{
if($this->convertEncoding) {
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding) ;
return mb_convert_encoding(
$value,
$this->toEncoding,
$this->fromEncoding) ;
}

return $value ;
@@ -119,7 +123,7 @@ class CsvGenerator
$handle = fopen($path, 'w+');

foreach ($this->arrayToExport as $line) {
fputcsv($handle, $line, ';', ' ');
fputcsv($handle, $line, $this->getDelimiter(), "\"");
}
fclose($handle);
}
@@ -143,7 +147,10 @@ class CsvGenerator
}



public function getDelimiter()
{
return $this->delimiter ;
}




+ 5
- 3
ShopBundle/Services/DocumentUtils.php Ver arquivo

@@ -67,12 +67,14 @@ class DocumentUtils
if(isset($params['merchant'])) {
$document->setMerchant($params['merchant']) ;
}
else {
elseif(isset($params['order_shops'])) {
$document->setMerchant($params['order_shops'][0]->getMerchant()) ;
}

foreach($params['order_shops'] as $orderShop) {
$document->addOrderShop($orderShop) ;
if(isset($params['order_shops'])) {
foreach ($params['order_shops'] as $orderShop) {
$document->addOrderShop($orderShop);
}
}

$document->setType($params['type']) ;

+ 1
- 1
ShopBundle/Services/MailUtils.php Ver arquivo

@@ -41,7 +41,7 @@ class MailUtils
$merchantCurrent = $this->merchantUtils->getMerchantCurrent();

$merchantConfigEmailFrom = $merchantCurrent->getMerchantConfig('email-from');
$emailFrom = isset($params[self::FROM_EMAIL]) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom;
$emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL])) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom;

$merchantConfigEmailFromName = $merchantCurrent->getMerchantConfig('email-from-name');
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName;

+ 39
- 42
ShopBundle/Services/Price/PriceUtils.php Ver arquivo

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Services\Price ;
namespace Lc\ShopBundle\Services\Price;

use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
@@ -10,59 +10,56 @@ use Lc\ShopBundle\Context\ProductPropertyInterface;

class PriceUtils implements PriceUtilsInterface
{
protected $productPriceUtils ;
protected $orderProductPriceUtils ;
protected $orderShopPriceUtils ;
protected $productPriceUtils;
protected $orderProductPriceUtils;
protected $orderShopPriceUtils;

public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils)
{
$this->productPriceUtils = $productPriceUtils ;
$this->orderProductPriceUtils = $orderProductPriceUtils ;
$this->orderShopPriceUtils = $orderShopPriceUtils ;
$this->productPriceUtils = $productPriceUtils;
$this->orderProductPriceUtils = $orderProductPriceUtils;
$this->orderShopPriceUtils = $orderShopPriceUtils;
}

public function __call($name, $arguments)
{
$entity = $arguments[0] ;
$service = '' ;
if (strpos($name, 'apply') === false) {
$entity = $arguments[0];
$service = '';

if($entity instanceof ProductPropertyInterface) {
$service = 'productPriceUtils' ;
}

if($entity instanceof OrderProductInterface) {
$service = 'orderProductPriceUtils' ;
}

if($entity instanceof OrderShopInterface || is_array($entity)) {
$service = 'orderShopPriceUtils' ;
}

if(strlen($service) && $entity && method_exists($this->$service, $name)) {
if(isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) {
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]) ;
}
elseif(isset($arguments[1]) && isset($arguments[2])) {
return $this->$service->$name($entity, $arguments[1], $arguments[2]) ;
}
elseif(isset($arguments[1])) {
return $this->$service->$name($entity, $arguments[1]) ;
if ($entity instanceof ProductPropertyInterface) {
$service = 'productPriceUtils';
}
else {
return $this->$service->$name($entity) ;

if ($entity instanceof OrderProductInterface) {
$service = 'orderProductPriceUtils';
}
}
else {
if(!strlen($service)) {
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.") ;

if ($entity instanceof OrderShopInterface || is_array($entity)) {
$service = 'orderShopPriceUtils';
}
else {
if(!method_exists($this->$service, $name)) {
throw new \ErrorException("PriceUtils : la méthode ".$name." du service ".$service." n'existe pas.") ;

if (strlen($service) && $entity && method_exists($this->$service, $name)) {
if (isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) {
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]);
} elseif (isset($arguments[1]) && isset($arguments[2])) {
return $this->$service->$name($entity, $arguments[1], $arguments[2]);
} elseif (isset($arguments[1])) {
return $this->$service->$name($entity, $arguments[1]);
} else {
return $this->$service->$name($entity);
}
} else {
if (!strlen($service)) {
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.");
} else {
if (!method_exists($this->$service, $name)) {
throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas.");
}
}
}
}

return false ;
return false;
}
}
}
}

+ 33
- 1
ShopBundle/Services/TicketUtils.php Ver arquivo

@@ -8,19 +8,23 @@ use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\TicketInterface;
use Lc\ShopBundle\Context\TicketMessageInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Model\Ticket;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

class TicketUtils
{
protected $em ;
protected $merchantUtils ;
protected $mailUtils ;
protected $authorizationChecker ;

public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, MailUtils $mailUtils)
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, MailUtils $mailUtils, AuthorizationCheckerInterface $authorizationChecker)
{
$this->em = $em ;
$this->merchantUtils = $merchantUtils ;
$this->mailUtils = $mailUtils ;
$this->authorizationChecker = $authorizationChecker ;
}

public function createTicket($params): TicketInterface
@@ -74,6 +78,9 @@ class TicketUtils
],
]) ;


$this->notifyAdmin($ticket, $ticketMessage);

return $ticket ;
}

@@ -114,5 +121,30 @@ class TicketUtils

return $ticketMessage ;
}

public function notifyAdmin($ticket, $ticketMessage){
$userRepo = $this->em->getRepository(UserInterface::class);
$usersToNotify = $userRepo->findByTicketTypesNotification($ticket->getType());


foreach ($usersToNotify as $userToNotify){

if($this->authorizationChecker->isGranted('ROLE_ADMIN', $userToNotify)){

// envoi email au client
$this->mailUtils->send([
MailUtils::SUBJECT => 'Nouveau ticket sur placedulocal',
MailUtils::TO_EMAIL => $userToNotify->getEmail(),
MailUtils::CONTENT_TEMPLATE => 'mail/ticket-notification',
MailUtils::CONTENT_DATA => [
'firstname' => $userToNotify->getFirstname(),
'ticket' => $ticket,
'ticketMessage' => $ticketMessage
],
]) ;
}
}

}
}


+ 3
- 2
ShopBundle/Services/UtilsManager.php Ver arquivo

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\DeliveryUtilsInterface;
use Lc\ShopBundle\Context\DocumentUtilsInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
@@ -35,7 +36,7 @@ class UtilsManager
PriceUtilsInterface $priceUtils,
DeliveryUtilsInterface $deliveryUtils,
CreditUtils $creditUtils,
DocumentUtils $documentUtils,
DocumentUtilsInterface $documentUtils,
MailUtils $mailUtils,
TicketUtils $ticketUtils,
PointLocationUtils $pointLocationUtils,
@@ -97,7 +98,7 @@ class UtilsManager
return $this->creditUtils ;
}

public function getDocumentUtils(): DocumentUtils
public function getDocumentUtils(): DocumentUtilsInterface
{
return $this->documentUtils ;
}

+ 5
- 0
ShopBundle/Services/UtilsProcess.php Ver arquivo

@@ -16,6 +16,7 @@ use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface;
use Lc\ShopBundle\Context\ReminderInterface;
use Lc\ShopBundle\Context\SluggableInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\ShopBundle\Context\UserInterface;
@@ -62,6 +63,10 @@ class UtilsProcess
$this->em->persist($newAddress);
}

if($newEntity instanceof SluggableInterface){
$newEntity->setTitle($newEntity->getTitle().' ');
}

$this->em->persist($newEntity);
if($flush){
$this->em->flush();

+ 5
- 1
ShopBundle/Twig/FrontendTwigExtension.php Ver arquivo

@@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
@@ -31,9 +32,11 @@ class FrontendTwigExtension extends AbstractExtension
protected $liipCacheHelper;
protected $parameterBag;
protected $kernel;
protected $router ;

public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils,
FormFactoryInterface $formFactory, RequestStack $requestStack, ParameterBagInterface $parameterBag, KernelInterface $kernel)
FormFactoryInterface $formFactory, RequestStack $requestStack, ParameterBagInterface $parameterBag,
KernelInterface $kernel, RouterInterface $router)
{
$this->em = $em;
$this->security = $security;
@@ -45,6 +48,7 @@ class FrontendTwigExtension extends AbstractExtension
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName());
$this->parameterBag = $parameterBag;
$this->kernel = $kernel;
$this->router = $router ;
}

public function getFunctions()

Carregando…
Cancelar
Salvar