1
0
Fork 0

Split and delete ModuleController

- $moduleName is part of the argument string => App\Arguments
- $isBackend boolean already part of App\Mode::isBackend()
- $module is now the direct return of App\Router::getModule()
- ModuleController::run() moved to BaseModule::run()
This commit is contained in:
Philipp Holzer 2021-11-19 22:47:49 +01:00
commit b5d2d32b44
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
17 changed files with 299 additions and 793 deletions

View file

@ -30,6 +30,8 @@ namespace Friendica\App;
*/
class Arguments
{
const DEFAULT_MODULE = 'home';
/**
* @var string The complete query string
*/
@ -38,6 +40,10 @@ class Arguments
* @var string The current Friendica command
*/
private $command;
/**
* @var string The name of the current module
*/
private $moduleName;
/**
* @var array The arguments of the current execution
*/
@ -47,10 +53,11 @@ class Arguments
*/
private $argc;
public function __construct(string $queryString = '', string $command = '', array $argv = [], int $argc = 0)
public function __construct(string $queryString = '', string $command = '', string $moduleName = '', array $argv = [], int $argc = 0)
{
$this->queryString = $queryString;
$this->command = $command;
$this->moduleName = $moduleName;
$this->argv = $argv;
$this->argc = $argc;
}
@ -71,6 +78,14 @@ class Arguments
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
*/
@ -172,6 +187,18 @@ 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";
}
return new Arguments($queryString, $command, $module, $argv, $argc);
}
}