![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-store-graph-ql/Plugin/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\StoreGraphQl\Plugin; use Magento\Framework\App\AreaInterface; use Magento\Framework\App\AreaList; use Magento\Framework\App\State; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Store\Model\App\Emulation; use Magento\Store\Model\StoreManagerInterface; /** * Emulate the correct store when GraphQL is sending an email */ class LocalizeEmail { /** * @var StoreManagerInterface */ private $storeManager; /** * @var Emulation */ private $emulation; /** * @var AreaList */ private $areaList; /** * @var State */ private $appState; /** * @param StoreManagerInterface $storeManager * @param Emulation $emulation * @param AreaList $areaList * @param State $appState */ public function __construct( StoreManagerInterface $storeManager, Emulation $emulation, AreaList $areaList, State $appState ) { $this->storeManager = $storeManager; $this->emulation = $emulation; $this->areaList = $areaList; $this->appState = $appState; } /** * Emulate the correct store during email preparation * * @param TransportBuilder $subject * @param \Closure $proceed * @return mixed * @throws NoSuchEntityException|LocalizedException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundGetTransport(TransportBuilder $subject, \Closure $proceed) { // Load translations for the app $area = $this->areaList->getArea($this->appState->getAreaCode()); $area->load(AreaInterface::PART_TRANSLATE); $currentStore = $this->storeManager->getStore(); $this->emulation->startEnvironmentEmulation($currentStore->getId()); $output = $proceed(); $this->emulation->stopEnvironmentEmulation(); return $output; } }