-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Franck Allimant
committed
Nov 16, 2023
1 parent
aedf6d9
commit a2d13ab
Showing
4 changed files
with
29 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
|
||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
|
||
namespace Brevo\Hook; | ||
|
||
|
@@ -18,14 +25,12 @@ | |
use Thelia\Core\Event\Hook\HookRenderEvent; | ||
use Thelia\Core\Hook\BaseHook; | ||
use Thelia\Core\HttpFoundation\Request; | ||
use Thelia\Core\Template\Assets\AssetResolverInterface; | ||
use Thelia\Model\ConfigQuery; | ||
use Thelia\Model\Customer; | ||
use TheliaSmarty\Template\SmartyParser; | ||
|
||
class HookManager extends BaseHook | ||
{ | ||
/** @var Request */ | ||
/** @var Request */ | ||
protected $request; | ||
|
||
public function __construct(RequestStack $requestStack, EventDispatcherInterface $eventDispatcher) | ||
|
@@ -35,30 +40,22 @@ public function __construct(RequestStack $requestStack, EventDispatcherInterface | |
$this->request = $requestStack->getCurrentRequest(); | ||
} | ||
|
||
public function onModuleConfiguration(HookRenderEvent $event) | ||
public function onModuleConfiguration(HookRenderEvent $event): void | ||
{ | ||
$event->add( | ||
$this->render("brevo-configuration.html") | ||
$this->render('brevo-configuration.html') | ||
); | ||
} | ||
|
||
public function onMainHeadTop(HookRenderEvent $event) | ||
public function onMainHeadTop(HookRenderEvent $event): void | ||
{ | ||
$apiKey = ConfigQuery::read(Brevo::CONFIG_API_SECRET); | ||
|
||
//$this->get('thelia.customer_user'); | ||
/** @var Customer $customer */ | ||
$customer = $this->request->getSession()->getCustomerUser(); | ||
|
||
$email = null; | ||
if ($customer !== null) { | ||
$email = $customer->getEmail(); | ||
} | ||
$customer = $this->request->getSession()?->getCustomerUser(); | ||
|
||
$event->add( | ||
$this->render("tracking_script.html",[ | ||
'apiKey' => $apiKey, | ||
'email' => $email | ||
$this->render('tracking_script.html', [ | ||
'marketingAutomationKey' => ConfigQuery::read(Brevo::CONFIG_AUTOMATION_KEY), | ||
'email' => $customer?->getEmail(), | ||
]) | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters