X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FApp%2FArguments.php;h=6dfdcb560fc9d453d069f9ab779697f7dff51c16;hb=e69b04d2df9726cd43a7c801febe8e4f7668f790;hp=ae6c64a4f39715db1577e29a04d7ec7e294f659a;hpb=3cef3ab107f87f999cf4adcc909259925a631cea;p=friendica.git diff --git a/src/App/Arguments.php b/src/App/Arguments.php index ae6c64a4f3..6dfdcb560f 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; } /** @@ -66,23 +78,39 @@ 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 + */ + public function getModuleName(): string + { + return $this->moduleName; + } + /** * @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; } @@ -117,7 +145,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); } @@ -130,7 +158,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'] ?? '', '/'); @@ -172,6 +200,20 @@ class Arguments $queryString = $command . ($queryParameters ? '?' . http_build_query($queryParameters) : ''); - return new Arguments($queryString, $command, $argv, $argc); + if ($argc > 0) { + $module = str_replace('.', '_', $argv[0]); + $module = str_replace('-', '_', $module); + } else { + $module = self::DEFAULT_MODULE; + } + + // Compatibility with the Firefox App + if (($module == "users") && ($command == "users/sign_in")) { + $module = "login"; + } + + $httpMethod = in_array($server['REQUEST_METHOD'] ?? '', Router::ALLOWED_METHODS) ? $server['REQUEST_METHOD'] : Router::GET; + + return new Arguments($queryString, $command, $module, $argv, $argc, $httpMethod); } }