forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-4828: [2.3] Database Media Storage - Transactional Emails will…
… now extract image from database in Database Media Storage mode magento#21674
- Loading branch information
Showing
3 changed files
with
41 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,12 @@ | |
use Magento\Store\Model\Information as StoreInformation; | ||
use Magento\Store\Model\ScopeInterface; | ||
use Magento\Store\Model\Store; | ||
use Magento\MediaStorage\Helper\File\Storage\Database; | ||
|
||
/** | ||
* Template model class | ||
* Template model class. | ||
* | ||
* phpcs:disable Magento2.Classes.AbstractApi | ||
* @author Magento Core Team <[email protected]> | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
* @SuppressWarnings(PHPMD.TooManyFields) | ||
|
@@ -163,6 +165,11 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn | |
*/ | ||
private $urlModel; | ||
|
||
/** | ||
* @var Database | ||
*/ | ||
private $fileStorageDatabase; | ||
|
||
/** | ||
* @param \Magento\Framework\Model\Context $context | ||
* @param \Magento\Framework\View\DesignInterface $design | ||
|
@@ -177,6 +184,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn | |
* @param \Magento\Framework\Filter\FilterManager $filterManager | ||
* @param \Magento\Framework\UrlInterface $urlModel | ||
* @param array $data | ||
* @param Database $fileStorageDatabase | ||
* | ||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) | ||
*/ | ||
|
@@ -193,7 +201,8 @@ public function __construct( | |
\Magento\Email\Model\TemplateFactory $templateFactory, | ||
\Magento\Framework\Filter\FilterManager $filterManager, | ||
\Magento\Framework\UrlInterface $urlModel, | ||
array $data = [] | ||
array $data = [], | ||
Database $fileStorageDatabase = null | ||
) { | ||
$this->design = $design; | ||
$this->area = isset($data['area']) ? $data['area'] : null; | ||
|
@@ -207,6 +216,8 @@ public function __construct( | |
$this->templateFactory = $templateFactory; | ||
$this->filterManager = $filterManager; | ||
$this->urlModel = $urlModel; | ||
$this->fileStorageDatabase = $fileStorageDatabase ?: | ||
\Magento\Framework\App\ObjectManager::getInstance()->get(Database::class); | ||
parent::__construct($context, $registry, null, null, $data); | ||
} | ||
|
||
|
@@ -394,6 +405,11 @@ protected function getLogoUrl($store) | |
if ($fileName) { | ||
$uploadDir = \Magento\Email\Model\Design\Backend\Logo::UPLOAD_DIR; | ||
$mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); | ||
if ($this->fileStorageDatabase->checkDbUsage() && | ||
!$mediaDirectory->isFile($uploadDir . '/' . $fileName) | ||
) { | ||
$this->fileStorageDatabase->saveFileToFilesystem($uploadDir . '/' . $fileName); | ||
} | ||
if ($mediaDirectory->isFile($uploadDir . '/' . $fileName)) { | ||
return $this->storeManager->getStore()->getBaseUrl( | ||
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA | ||
|
@@ -490,7 +506,6 @@ protected function addEmailVariables($variables, $storeId) | |
|
||
/** | ||
* Apply design config so that emails are processed within the context of the appropriate area/store/theme. | ||
* Can be called multiple times without issue. | ||
* | ||
* @return bool | ||
*/ | ||
|
@@ -664,8 +679,7 @@ public function getTemplateFilter() | |
} | ||
|
||
/** | ||
* Save current design config and replace with design config from specified store | ||
* Event is not dispatched. | ||
* Save current design config and replace with design config from specified store. Event is not dispatched. | ||
* | ||
* @param null|bool|int|string $storeId | ||
* @param string $area | ||
|
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