-
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 branch '2.3-develop-mainline' into PULL-12965-FORWARDPORT
- Loading branch information
Showing
85 changed files
with
2,753 additions
and
385 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
31 changes: 31 additions & 0 deletions
31
app/code/Magento/GraphQl/Controller/HttpHeaderProcessor/ContentTypeProcessor.php
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,31 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\GraphQl\Controller\HttpHeaderProcessor; | ||
|
||
use Magento\Framework\GraphQl\HttpHeaderProcessorInterface; | ||
use Magento\Framework\Exception\LocalizedException; | ||
|
||
/** | ||
* Processes the "Content-Type" header entry | ||
*/ | ||
class ContentTypeProcessor implements HttpHeaderProcessorInterface | ||
{ | ||
/** | ||
* Handle the mandatory application/json header | ||
* | ||
* {@inheritDoc} | ||
* @throws LocalizedException | ||
*/ | ||
public function processHeaderValue($headerValue) | ||
{ | ||
if (!$headerValue || strpos($headerValue, 'application/json') === false) { | ||
throw new LocalizedException( | ||
new \Magento\Framework\Phrase('Request content type must be application/json') | ||
); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
app/code/Magento/GraphQl/Controller/HttpHeaderProcessor/StoreProcessor.php
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,53 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\GraphQl\Controller\HttpHeaderProcessor; | ||
|
||
use Magento\Framework\GraphQl\HttpHeaderProcessorInterface; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
use Magento\Framework\GraphQl\Exception\GraphQlInputException; | ||
|
||
/** | ||
* Process the "Store" header entry | ||
*/ | ||
class StoreProcessor implements HttpHeaderProcessorInterface | ||
{ | ||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* StoreProcessor constructor. | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct(StoreManagerInterface $storeManager) | ||
{ | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* Handle the value of the store and set the scope | ||
* | ||
* {@inheritDoc} | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function processHeaderValue($headerValue) | ||
{ | ||
if ($headerValue) { | ||
$storeCode = ltrim(rtrim($headerValue)); | ||
$stores = $this->storeManager->getStores(false, true); | ||
if (isset($stores[$storeCode])) { | ||
$this->storeManager->setCurrentStore($storeCode); | ||
} elseif (strtolower($storeCode) !== 'default') { | ||
throw new GraphQlInputException( | ||
new \Magento\Framework\Phrase('Store code %1 does not exist', [$storeCode]) | ||
); | ||
} | ||
} | ||
} | ||
} |
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
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.