Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
App
Request
HttpMethodValidator.php
Go to the documentation of this file.
1
<?php
7
declare(strict_types=1);
8
9
namespace
Magento\Framework\App\Request
;
10
11
use
Magento\Framework\App\ActionInterface
;
12
use
Magento\Framework\App\RequestInterface
;
13
use
Magento\Framework\Exception\NotFoundException
;
14
use
Magento\Framework\Interception\InterceptorInterface
;
15
use
Magento\Framework\Phrase
;
16
use Psr\Log\LoggerInterface;
17
21
class
HttpMethodValidator
implements
ValidatorInterface
22
{
26
private
$map;
27
31
private
$log;
32
37
public
function
__construct
(
38
HttpMethodMap
$map,
39
LoggerInterface
$logger
40
) {
41
$this->map =
$map
;
42
$this->log =
$logger
;
43
}
44
54
private
function
throwException(
55
Http
$request
,
56
ActionInterface
$action
57
): void {
58
$uri =
$request
->getRequestUri();
59
$method
=
$request
->getMethod();
60
if
($action instanceof
InterceptorInterface
) {
61
$actionClass = get_parent_class($action);
62
}
else
{
63
$actionClass = get_class($action);
64
}
65
$this->log->debug(
66
"URI '$uri'' cannot be accessed with $method method ($actionClass)"
67
);
68
69
throw
new
InvalidRequestException(
70
new
NotFoundException(
new
Phrase
(
'Page not found.'
))
71
);
72
}
73
77
public
function
validate
(
78
RequestInterface
$request
,
79
ActionInterface
$action
80
): void {
81
if
(
$request
instanceof
Http
) {
82
$method
=
$request
->getMethod();
83
$map = $this->map->getMap();
84
//If we don't have an interface for the HTTP method or
85
//the action has HTTP method limitations and doesn't allow the
86
//received one then the request is invalid.
87
if
(!array_key_exists(
$method
, $map)
88
|| (array_intersect($map, class_implements($action,
true
))
89
&& !$action instanceof $map[
$method
]
90
)
91
) {
92
$this->throwException(
$request
, $action);
93
}
94
}
95
}
96
}
$map
$map
Definition:
classmap_generator.php:167
Magento\Framework\App\Request\HttpMethodValidator\validate
validate(RequestInterface $request, ActionInterface $action)
Definition:
HttpMethodValidator.php:77
$logger
$logger
Definition:
health_check.php:20
Magento\Framework\App\Request\HttpMethodValidator\__construct
__construct(HttpMethodMap $map, LoggerInterface $logger)
Definition:
HttpMethodValidator.php:37
Magento\Framework\App\Request\Http
Definition:
Http.php:20
Magento\Framework\Exception\NotFoundException
Definition:
NotFoundException.php:12
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
Magento\Framework\App\ActionInterface
Definition:
ActionInterface.php:14
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
$method
$method
Definition:
info.phtml:13
Magento\Framework\App\Request\HttpMethodValidator
Definition:
HttpMethodValidator.php:21
Magento\Framework\Interception\InterceptorInterface
Definition:
InterceptorInterface.php:14
Magento\Framework\Phrase
Definition:
Phrase.php:17
Magento\Framework\Phrase
Magento\Framework\App\Request
Definition:
CompositeValidator.php:9
Magento\Framework\App\Request\ValidatorInterface
Definition:
ValidatorInterface.php:17
Magento\Framework\App\Request\HttpMethodMap
Definition:
HttpMethodMap.php:14