X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp%2FArguments.php;h=6f527d2f4def937fa4a7619690455422f98253cb;hb=e659a0314086dd700dbe5e754e383ab758725805;hp=19f8e9212310d8cef413d544a4e1b4d92adf44f9;hpb=5aad46c7fb2b66d63ad93d92ee355fc522b57be1;p=friendica.git diff --git a/src/App/Arguments.php b/src/App/Arguments.php index 19f8e92123..6f527d2f4d 100644 --- a/src/App/Arguments.php +++ b/src/App/Arguments.php @@ -1,6 +1,6 @@ queryString = $queryString; $this->command = $command; $this->moduleName = $moduleName; $this->argv = $argv; $this->argc = $argc; + $this->method = $method; } /** @@ -73,13 +78,15 @@ class Arguments /** * @return string The whole command of this call */ - public function getCommand() + public function getCommand(): string { return $this->command; } /** * @return string The module name based on the arguments + * @deprecated 2022.12 - With the new (sub-)routes, it's not trustworthy anymore, use the ModuleClass instead + * @see Router::getModuleClass() */ public function getModuleName(): string { @@ -89,15 +96,23 @@ class Arguments /** * @return array All arguments of this call */ - public function getArgv() + public function getArgv(): array { return $this->argv; } + /** + * @return string The used HTTP method + */ + public function getMethod(): string + { + return $this->method; + } + /** * @return int The count of arguments of this call */ - public function getArgc() + public function getArgc(): int { return $this->argc; } @@ -132,7 +147,7 @@ class Arguments * * @return bool if the argument position exists */ - public function has(int $position) + public function has(int $position): bool { return array_key_exists($position, $this->argv); } @@ -145,7 +160,7 @@ class Arguments * * @return Arguments The determined arguments */ - public function determine(array $server, array $get) + public function determine(array $server, array $get): Arguments { // removing leading / - maybe a nginx problem $server['QUERY_STRING'] = ltrim($server['QUERY_STRING'] ?? '', '/'); @@ -199,6 +214,8 @@ class Arguments $module = "login"; } - return new Arguments($queryString, $command, $module, $argv, $argc); + $httpMethod = in_array($server['REQUEST_METHOD'] ?? '', Router::ALLOWED_METHODS) ? $server['REQUEST_METHOD'] : Router::GET; + + return new Arguments($queryString, $command, $module, $argv, $argc, $httpMethod); } }