Use Args::getMethod() at various places

This commit is contained in:
Philipp 2022-01-02 22:25:50 +01:00
parent ee2a15d822
commit 4e67bfed8d
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
5 changed files with 6 additions and 15 deletions

View file

@ -74,11 +74,6 @@ class Router
/** @var RouteCollector */
protected $routeCollector;
/**
* @var string The HTTP method
*/
private $httpMethod;
/**
* @var array Module parameters
*/
@ -139,10 +134,6 @@ class Router
$this->logger = $logger;
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
$httpMethod = $this->server['REQUEST_METHOD'] ?? self::GET;
$this->httpMethod = in_array($httpMethod, self::ALLOWED_METHODS) ? $httpMethod : self::GET;
$this->routeCollector = isset($routeCollector) ?
$routeCollector :
new RouteCollector(new Std(), new GroupCountBased());
@ -271,12 +262,12 @@ class Router
$this->parameters = [];
$routeInfo = $dispatcher->dispatch($this->httpMethod, $cmd);
$routeInfo = $dispatcher->dispatch($this->args->getMethod(), $cmd);
if ($routeInfo[0] === Dispatcher::FOUND) {
$moduleClass = $routeInfo[1];
$this->parameters = $routeInfo[2];
} elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
if ($this->httpMethod === static::OPTIONS) {
if ($this->args->getMethod() === static::OPTIONS) {
// Default response for HTTP OPTIONS requests in case there is no special treatment
$moduleClass = Options::class;
} else {