-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6022 from magento-obsessive-owls/PWA-805-group
[Owls] PWA-805: Expose localization system / store config from GraphQL
- Loading branch information
Showing
16 changed files
with
673 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
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,83 @@ | ||
<?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; | ||
} | ||
} |
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
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
Oops, something went wrong.