mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-07 09:17:35 +00:00
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Magento\Webapi\Controller\Rest;
|
|
|
|
/**
|
|
* Request Processor Pool
|
|
*/
|
|
class RequestProcessorPool
|
|
{
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private $requestProcessors;
|
|
|
|
/**
|
|
* Initial dependencies
|
|
*
|
|
* @param RequestProcessorInterface[] $requestProcessors
|
|
*/
|
|
public function __construct($requestProcessors = [])
|
|
{
|
|
$this->requestProcessors = $requestProcessors;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*
|
|
* @throws \Magento\Framework\Webapi\Exception
|
|
* return RequestProcessorInterface
|
|
*/
|
|
public function getProcessor(\Magento\Framework\Webapi\Rest\Request $request)
|
|
{
|
|
foreach ($this->requestProcessors as $processor) {
|
|
if ($processor->canProcess($request)) {
|
|
return $processor;
|
|
}
|
|
}
|
|
|
|
throw new \Magento\Framework\Webapi\Exception(
|
|
__('Specified request cannot be processed.'),
|
|
0,
|
|
\Magento\Framework\Webapi\Exception::HTTP_BAD_REQUEST
|
|
);
|
|
}
|
|
}
|