Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #436 from elcodi/fix/emails-override
Browse files Browse the repository at this point in the history
Added emails override and fixed data fixtures
  • Loading branch information
mmoreram committed May 7, 2015
2 parents 13b7c79 + 9ec5ec4 commit b30a196
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ admin:
title:
title: Título
placeholder: p.e. Mi magnífico correo
title:
content:
title: Contenido
placeholder: p.e. Este magnífico correo es exactamente lo que buscabas.
section:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ admin:
title:
title: Title
placeholder: e.g. My Awesome Mailing
title:
content:
title: Content
placeholder: e.g. This awesome mailing is exactly what you are lookin for.
section:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ admin:
title:
title: Título
placeholder: ej. Mi magnífico correo
title:
content:
title: Contenido
placeholder: ej. Este magnífico correo es exactamente lo que buscabas.
section:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ admin:
title:
title: Titre
placeholder: e.g. Ma super campagne
title:
content:
title: Contenu
placeholder: e.g. Cette super campagne est exactement ce que vous recherchez.
section:
Expand Down
8 changes: 4 additions & 4 deletions src/Elcodi/Fixtures/DataFixtures/ORM/Page/PageData.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function load(ObjectManager $manager)
*/
$customerRegistrationEmail = $pageDirector
->create()
->setTitle('Registro de nuevo usuario')
->setTitle('Bienvenido!')
->setContent('Hola {{ customer.fullname }}. Le damos la Bienvenida.')
->setName('customer_registration')
->setType(ElcodiPageTypes::TYPE_EMAIL)
Expand All @@ -244,7 +244,7 @@ public function load(ObjectManager $manager)

$entityTranslator->save($customerRegistrationEmail, [
'es' => [
'title' => 'Confirmación de pedido',
'title' => 'Bienvenido!',
'content' => 'Hola {{ customer.fullname }}. Le damos la Bienvenida.',
],
]);
Expand Down Expand Up @@ -276,7 +276,7 @@ public function load(ObjectManager $manager)
*/
$passwordRecoverEmail = $pageDirector
->create()
->setTitle('Recordatorio de contraseña')
->setTitle('Contraseña recuperada')
->setContent('Hola {{ customer.fullname }}. Tu contraseña ha sido recuperada.')
->setName('password_recover')
->setType(ElcodiPageTypes::TYPE_EMAIL)
Expand All @@ -288,7 +288,7 @@ public function load(ObjectManager $manager)

$entityTranslator->save($passwordRecoverEmail, [
'es' => [
'title' => 'Recordatorio de contraseña',
'title' => 'Contraseña recuperada',
'content' => 'Hola {{ customer.fullname }}. Tu contraseña ha sido recuperada.',
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function getConfigFiles(array $config)
return [
'eventListeners',
'twig',
'services',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use Elcodi\Component\Page\Entity\Interfaces\PageInterface;
use Elcodi\Component\Page\Repository\PageRepository;
use Elcodi\Store\CoreBundle\Services\TemplateLocator;

/**
* Class AbstractEmailSenderEventListener
Expand Down Expand Up @@ -49,6 +50,13 @@ abstract class AbstractEmailSenderEventListener
*/
protected $pageRepository;

/**
* @var TemplateLocator
*
* Template locator
*/
protected $templateLocator;

/**
* @var string
*
Expand All @@ -59,20 +67,23 @@ abstract class AbstractEmailSenderEventListener
/**
* Construct
*
* @param Swift_Mailer $mailer Mailer
* @param Twig_Environment $twig Twig
* @param PageRepository $pageRepository Page repository
* @param string $storeEmail Store email
* @param Swift_Mailer $mailer Mailer
* @param Twig_Environment $twig Twig
* @param PageRepository $pageRepository Page repository
* @param TemplateLocator $templateLocator A template locator
* @param string $storeEmail Store email
*/
public function __construct(
Swift_Mailer $mailer,
Twig_Environment $twig,
PageRepository $pageRepository,
TemplateLocator $templateLocator,
$storeEmail
) {
$this->mailer = $mailer;
$this->twig = $twig;
$this->pageRepository = $pageRepository;
$this->templateLocator = $templateLocator;
$this->storeEmail = $storeEmail;
}

Expand All @@ -92,9 +103,14 @@ protected function sendEmail($emailName, array $context, $receiverEmail)
]);

if ($page instanceof PageInterface) {
$template = $this
->templateLocator
->locate(':email.html.twig');

$resolvedPage = $this
->twig
->render('StorePageBundle::email.html.twig', array_merge([
->render($template, array_merge([
'title' => $page->getTitle(),
'content' => $page->getContent(),
], $context));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ services:
- @mailer
- @twig
- @elcodi.repository.page
- @store.page.services.template_locator
- @=elcodi_config("store.email")
13 changes: 13 additions & 0 deletions src/Elcodi/Store/PageBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:

#
# Services
#
store.page.services.template_locator:
class: Elcodi\Store\CoreBundle\Services\TemplateLocator
arguments:
engine: @templating.engine.twig
bundles:
- StoreOverrideBundle
- StorePageBundle
- StoreFallbackBundle

0 comments on commit b30a196

Please sign in to comment.