-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(email): set scope correctly on admin emails
- Loading branch information
1 parent
e53fd3a
commit bc984a6
Showing
4 changed files
with
72 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Graycore, LLC. All rights reserved. | ||
* See LICENSE.md for details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Graycore\Daffodil\Plugins; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Graycore\Daffodil\Configuration\Configuration; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
class EmulatedAdminEmailUrls | ||
{ | ||
private $_configuration; | ||
private $_urlModel; | ||
private $_store; | ||
|
||
private $originalScope; | ||
/** | ||
* @param ScopeConfigInterface $scopeConfig | ||
*/ | ||
public function __construct( | ||
\Magento\Framework\UrlInterface $urlModel, | ||
Configuration $configuration, | ||
StoreManagerInterface $store | ||
) { | ||
$this->_configuration = $configuration; | ||
$this->_urlModel = $urlModel; | ||
$this->_store = $store; | ||
} | ||
|
||
public function beforeGetTransport() | ||
{ | ||
if ($this->_configuration->isActive()) { | ||
$this->originalScope = $this->_urlModel->getScope(); | ||
$this->_urlModel->setScope($this->_store->getStore()); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function afterGetTransport($subject, $result) | ||
{ | ||
if ($this->_configuration->isActive()) { | ||
$this->_urlModel->setScope($this->originalScope); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Framework\Mail\Template\TransportBuilder"> | ||
<plugin | ||
name="updateUrlsForFrontendEmailsSentFromAdmin" type="Graycore\Daffodil\Plugins\EmulatedAdminEmailUrls" /> | ||
</type> | ||
</config> |