make App\Router easier
This commit is contained in:
parent
7b35c570f9
commit
f15878195c
@ -99,8 +99,8 @@ class Router
|
|||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
/** @var IHandleUserSessions */
|
/** @var bool */
|
||||||
private $userSession;
|
private $isLocalUser;
|
||||||
|
|
||||||
/** @var float */
|
/** @var float */
|
||||||
private $dice_profiler_threshold;
|
private $dice_profiler_threshold;
|
||||||
@ -138,7 +138,7 @@ class Router
|
|||||||
$this->dice = $dice;
|
$this->dice = $dice;
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->userSession = $userSession;
|
$this->isLocalUser = !empty($userSession->getLocalUserId());
|
||||||
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
|
$this->dice_profiler_threshold = $config->get('system', 'dice_profiler_threshold', 0);
|
||||||
|
|
||||||
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
|
$this->routeCollector = $routeCollector ?? new RouteCollector(new Std(), new GroupCountBased());
|
||||||
@ -314,7 +314,7 @@ class Router
|
|||||||
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
|
if (Addon::isEnabled($moduleName) && file_exists("addon/{$moduleName}/{$moduleName}.php")) {
|
||||||
//Check if module is an app and if public access to apps is allowed or not
|
//Check if module is an app and if public access to apps is allowed or not
|
||||||
$privateapps = $this->config->get('config', 'private_addons', false);
|
$privateapps = $this->config->get('config', 'private_addons', false);
|
||||||
if (!$this->userSession->getLocalUserId() && Hook::isAddonApp($moduleName) && $privateapps) {
|
if (!$this->isLocalUser && Hook::isAddonApp($moduleName) && $privateapps) {
|
||||||
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
|
throw new MethodNotAllowedException($this->l10n->t("You must be logged in to use addons. "));
|
||||||
} else {
|
} else {
|
||||||
include_once "addon/{$moduleName}/{$moduleName}.php";
|
include_once "addon/{$moduleName}/{$moduleName}.php";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user