Sfoglia il codice sorgente

[Backofiice] Bon de commande : envoie du bon avec email en copie caché

feature/export_comptable
Fab 4 anni fa
parent
commit
dddf91ec8f
2 ha cambiato i file con 57 aggiunte e 0 eliminazioni
  1. +46
    -0
      ShopBundle/Form/DataTransformer/StreetNumberTransformer.php
  2. +11
    -0
      ShopBundle/Services/MailUtils.php

+ 46
- 0
ShopBundle/Form/DataTransformer/StreetNumberTransformer.php Vedi File

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

namespace Lc\ShopBundle\Form\DataTransformer;

use Lc\ShopBundle\Context\ProductInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

class ProductToIdTransformer implements DataTransformerInterface
{
private $em ;

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

public function transform($product)
{

if (null === $product) {
return '';
}

return $product->getId();
}

public function reverseTransform($productId)
{
if (!$productId) {
return;
}

$product = $this->em->getRepository($this->em->getClassMetadata(ProductInterface::class)->getName())->find($productId);

if (null === $product) {
throw new TransformationFailedException(sprintf(
'An issue with number "%s" does not exist!',
$productId
));
}

return $product;
}
}

+ 11
- 0
ShopBundle/Services/MailUtils.php Vedi File

@@ -13,6 +13,8 @@ class MailUtils
const SUBJECT = 'subject';
const SUBJECT_PREFIX = 'subject-prefix';
const TO_EMAIL = 'to-email';
const COPY_TO = 'copy-to';
const COPY_HIDDEN_TO = 'copy-hidden-to';
const TO_NAME = 'to-name';
const FROM_EMAIL = 'from-email';
const FROM_NAME = 'from-name';
@@ -73,6 +75,15 @@ class MailUtils
->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData), 'text/html')
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));

if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
$message->addCc($params[self::COPY_TO]);
}

if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
$message->addBcc($params[self::COPY_HIDDEN_TO]);
}


if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
$message->addReplyTo($params[self::REPLY_TO]);
}

Loading…
Annulla
Salva