]> git.mxchange.org Git - friendica.git/blobdiff - src/App/Arguments.php
Only add the media for non federated posts
[friendica.git] / src / App / Arguments.php
index ef1ed928563ea72665f17138c2776d0c012ea8d9..6dfdcb560fc9d453d069f9ab779697f7dff51c16 100644 (file)
@@ -52,14 +52,19 @@ class Arguments
         * @var int The count of arguments
         */
        private $argc;
+       /**
+        * @var string The used HTTP method
+        */
+       private $method;
 
-       public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0)
+       public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0, string $method = Router::GET)
        {
                $this->queryString = $queryString;
                $this->command     = $command;
                $this->moduleName  = $moduleName;
                $this->argv        = $argv;
                $this->argc        = $argc;
+               $this->method      = $method;
        }
 
        /**
@@ -73,7 +78,7 @@ class Arguments
        /**
         * @return string The whole command of this call
         */
-       public function getCommand()
+       public function getCommand(): string
        {
                return $this->command;
        }
@@ -89,15 +94,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 +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);
        }
@@ -145,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'] ?? '', '/');
@@ -199,6 +212,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);
        }
 }