Browse Source

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

develop
Fab 3 years ago
parent
commit
9ba5c091f1
6 changed files with 68 additions and 11 deletions
  1. +13
    -1
      ShopBundle/Model/OrderShop.php
  2. +4
    -0
      ShopBundle/Model/Product.php
  3. +2
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  4. +7
    -3
      ShopBundle/Services/MailUtils.php
  5. +33
    -6
      ShopBundle/Services/MailjetSmsUtils.php
  6. +9
    -1
      ShopBundle/Services/UtilsManager.php

+ 13
- 1
ShopBundle/Model/OrderShop.php View File

@@ -303,8 +303,20 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
/**
* @return Collection|OrderPayment[]
*/
public function getOrderPayments(): Collection
public function getOrderPayments($meanPayment = null): Collection
{
if($meanPayment) {
$orderPaymentsReturn = new ArrayCollection() ;

foreach($this->orderPayments as $orderPayment) {
if($orderPayment->getMeanPayment() == $meanPayment) {
$orderPaymentsReturn[] = $orderPayment ;
}
}

return $orderPaymentsReturn ;
}

return $this->orderPayments;
}


+ 4
- 0
ShopBundle/Model/Product.php View File

@@ -66,6 +66,10 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
$title .= ' - ' . $this->getTitle();
}

if($this->getProductFamily()->hasProductsWithVariousWeight()) {
$title .= ' - '.$this->getQuantityLabelInherited() ;
}

return $title;
}


+ 2
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

@@ -98,6 +98,8 @@ group:
listLoopBesancon: Adresses de Besançon à spécifier (lat / long)
User:
item: Utilisateur
Notification:
main: Notifications




+ 7
- 3
ShopBundle/Services/MailUtils.php View File

@@ -31,8 +31,12 @@ class MailUtils
protected $parameterBag;
protected $merchantUtils;

public function __construct(MailjetTransport $mailjetTransport, Environment $templating, ParameterBagInterface $parameterBag, MerchantUtilsInterface $merchantUtils)
{
public function __construct(
MailjetTransport $mailjetTransport,
Environment $templating,
ParameterBagInterface $parameterBag,
MerchantUtilsInterface $merchantUtils
) {
$this->transport = $mailjetTransport;
$this->templating = $templating;
$this->parameterBag = $parameterBag;
@@ -105,6 +109,6 @@ class MailUtils
$message->getHeaders()->addMailboxHeader('Disposition-Notification-To', $emailFromDispositionNotificationTo);
}*/

$this->transport->send($message);
return $this->transport->send($message);
}
}

ShopBundle/Services/MailjetSMS.php → ShopBundle/Services/MailjetSmsUtils.php View File

@@ -5,28 +5,55 @@ namespace Lc\ShopBundle\Services;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Twig\Environment;

class MailjetSMS
class MailjetSmsUtils
{
const TO_USER = 'to-user' ;
const CONTENT_MESSAGE = 'content-message' ;
const CONTENT_TEMPLATE = 'content-template' ;
const CONTENT_DATA = 'content-data' ;

protected $client;
protected $parameterBag;
protected $mailUtils ;
protected $utils ;
protected $templating ;

public function __construct(HttpClientInterface $client, ParameterBagInterface $parameterBag, UtilsManager $utilsManager)
{
public function __construct(
HttpClientInterface $client,
ParameterBagInterface $parameterBag,
MailUtils $mailUtils,
Utils $utils,
Environment $templating
) {
$this->client = $client;
$this->parameterBag = $parameterBag;
$this->mailUtils = $utilsManager->getMailUtils() ;
$this->utils = $utilsManager->getUtils() ;
$this->mailUtils = $mailUtils ;
$this->utils = $utils ;
$this->templating = $templating ;
}

public function send($user, $message)
public function send($params = [])
{
$user = isset($params[self::TO_USER]) ? $params[self::TO_USER] : null ;

if($user) {
$phone = $this->utils->formatPhoneNumber($user->getPhone()) ;

$message = '' ;
if(isset($params[self::CONTENT_MESSAGE])) {
$message = $params[self::CONTENT_MESSAGE] ;
}
elseif(isset($params[self::CONTENT_TEMPLATE])) {
$template = $params[self::CONTENT_TEMPLATE] ;
$paramsTemplate = [] ;
if(isset($params[self::CONTENT_DATA]) && is_array($params[self::CONTENT_DATA])) {
$paramsTemplate = $params[self::CONTENT_DATA] ;
}
$message = $this->templating->render($template, $paramsTemplate) ;
}

if($this->parameterBag->get('mailjet.dev.redirect.active') == 1) {
$this->mailUtils->send([
MailUtils::SUBJECT => 'Notification par SMS à '.$phone,

+ 9
- 1
ShopBundle/Services/UtilsManager.php View File

@@ -29,6 +29,7 @@ class UtilsManager
protected $statisticsUtils;
protected $pointLocationUtils ;
protected $sectionUtils ;
protected $mailjetSmsUtils ;

public function __construct(
Utils $utils,
@@ -44,7 +45,8 @@ class UtilsManager
TicketUtils $ticketUtils,
PointLocationUtils $pointLocationUtils,
UtilsProcess $utilsProcess,
SectionUtilsInterface $sectionUtils
SectionUtilsInterface $sectionUtils,
MailjetSmsUtils $mailjetSmsUtils
)
{
$this->utils = $utils ;
@@ -61,6 +63,7 @@ class UtilsManager
$this->pointLocationUtils = $pointLocationUtils ;
$this->utilsProcess = $utilsProcess ;
$this->sectionUtils = $sectionUtils ;
$this->mailjetSmsUtils = $mailjetSmsUtils ;
}

public function getUtils(): Utils
@@ -133,4 +136,9 @@ class UtilsManager
return $this->sectionUtils ;
}

public function getMailjetSmsUtils(): MailjetSmsUtils
{
return $this->mailjetSmsUtils ;
}

}

Loading…
Cancel
Save