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.
Merge branch '2.4-develop' into fix-27489
- Loading branch information
Showing
340 changed files
with
6,035 additions
and
17,415 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
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
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
62 changes: 62 additions & 0 deletions
62
app/code/Magento/Catalog/Model/Product/Webapi/Rest/RequestTypeBasedDeserializer.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,62 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product\Webapi\Rest; | ||
|
||
use Magento\Framework\Webapi\Rest\Request\DeserializerInterface; | ||
use Magento\Framework\Webapi\Rest\Request\DeserializerFactory; | ||
use Magento\Framework\Webapi\Rest\Request; | ||
|
||
/** | ||
* Class RequestTypeBasedDeserializer | ||
* | ||
* Used for deserialization rest request body. | ||
* Runs appropriate deserialization class object based on request body content type. | ||
*/ | ||
class RequestTypeBasedDeserializer implements DeserializerInterface | ||
{ | ||
/** | ||
* @var Request | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @var DeserializerFactory | ||
*/ | ||
private $deserializeFactory; | ||
|
||
/** | ||
* RequestTypeBasedDeserializer constructor. | ||
* | ||
* @param DeserializerFactory $deserializeFactory | ||
* @param Request $request | ||
*/ | ||
public function __construct( | ||
DeserializerFactory $deserializeFactory, | ||
Request $request | ||
) { | ||
$this->deserializeFactory = $deserializeFactory; | ||
$this->request = $request; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* | ||
* Parse request body into array of params with identifying request body content type | ||
* to use appropriate instance of deserializer class | ||
* | ||
* @param string $body Posted content from request | ||
* @return array|null Return NULL if content is invalid | ||
* @throws \Magento\Framework\Exception\InputException | ||
* @throws \Magento\Framework\Webapi\Exception | ||
*/ | ||
public function deserialize($body) | ||
{ | ||
$deserializer = $this->deserializeFactory->get($this->request->getContentType()); | ||
return $deserializer->deserialize($body); | ||
} | ||
} |
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.