mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 16:36:59 +01:00
chore: Bootstrap refactoring
Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -27,17 +27,20 @@ namespace SP\Modules\Web\Controllers\Bootstrap;
|
||||
use Exception;
|
||||
use JsonException;
|
||||
use SP\Core\Application;
|
||||
use SP\Core\Bootstrap\BootstrapBase;
|
||||
use SP\Core\Crypt\CryptPKI;
|
||||
use SP\Domain\Core\Crypt\CryptPKIInterface;
|
||||
use SP\Domain\Import\Services\ImportService;
|
||||
use SP\Domain\Core\Exceptions\SPException;
|
||||
use SP\Domain\Import\Services\ImportStrategy;
|
||||
use SP\Domain\Plugin\Ports\PluginManagerService;
|
||||
use SP\Infrastructure\File\FileException;
|
||||
use SP\Modules\Web\Controllers\SimpleControllerBase;
|
||||
use SP\Modules\Web\Controllers\Traits\JsonTrait;
|
||||
use SP\Mvc\Controller\SimpleControllerHelper;
|
||||
use SP\Plugin\PluginManager;
|
||||
use SP\Providers\Auth\Browser\BrowserAuthService;
|
||||
|
||||
use function SP\logger;
|
||||
use function SP\processException;
|
||||
|
||||
/**
|
||||
* Class GetEnvironmentController
|
||||
*
|
||||
@@ -47,21 +50,13 @@ final class GetEnvironmentController extends SimpleControllerBase
|
||||
{
|
||||
use JsonTrait;
|
||||
|
||||
private CryptPKIInterface $cryptPKI;
|
||||
private PluginManager $pluginManager;
|
||||
private BrowserAuthService $browser;
|
||||
|
||||
public function __construct(
|
||||
Application $application,
|
||||
SimpleControllerHelper $simpleControllerHelper,
|
||||
CryptPKIInterface $cryptPKI,
|
||||
PluginManager $pluginManager,
|
||||
BrowserAuthService $browser
|
||||
Application $application,
|
||||
SimpleControllerHelper $simpleControllerHelper,
|
||||
private readonly CryptPKIInterface $cryptPKI,
|
||||
private readonly BrowserAuthService $browser,
|
||||
private readonly PluginManagerService $pluginManagerService
|
||||
) {
|
||||
$this->cryptPKI = $cryptPKI;
|
||||
$this->pluginManager = $pluginManager;
|
||||
$this->browser = $browser;
|
||||
|
||||
parent::__construct($application, $simpleControllerHelper);
|
||||
}
|
||||
|
||||
@@ -70,6 +65,7 @@ final class GetEnvironmentController extends SimpleControllerBase
|
||||
*
|
||||
* @return bool
|
||||
* @throws JsonException
|
||||
* @throws SPException
|
||||
*/
|
||||
public function getEnvironmentAction(): bool
|
||||
{
|
||||
@@ -78,25 +74,25 @@ final class GetEnvironmentController extends SimpleControllerBase
|
||||
|| $this->configData->isDemoEnabled());
|
||||
|
||||
$data = [
|
||||
'lang' => $this->getJsLang(),
|
||||
'locale' => $this->configData->getSiteLang(),
|
||||
'app_root' => BootstrapBase::$WEBURI,
|
||||
'max_file_size' => $this->configData->getFilesAllowedSize(),
|
||||
'check_updates' => $checkStatus && $this->configData->isCheckUpdates(),
|
||||
'check_notices' => $checkStatus && $this->configData->isCheckNotices(),
|
||||
'lang' => $this->getJsLang(),
|
||||
'locale' => $this->configData->getSiteLang(),
|
||||
'app_root' => $this->uriContext->getWebUri(),
|
||||
'max_file_size' => $this->configData->getFilesAllowedSize(),
|
||||
'check_updates' => $checkStatus && $this->configData->isCheckUpdates(),
|
||||
'check_notices' => $checkStatus && $this->configData->isCheckNotices(),
|
||||
'check_notifications' => $this->getNotificationsEnabled(),
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'debug' => DEBUG || $this->configData->isDebug(),
|
||||
'cookies_enabled' => $this->getCookiesEnabled(),
|
||||
'plugins' => $this->getPlugins(),
|
||||
'loggedin' => $this->session->isLoggedIn(),
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'debug' => DEBUG || $this->configData->isDebug(),
|
||||
'cookies_enabled' => $this->getCookiesEnabled(),
|
||||
'plugins' => $this->getPlugins(),
|
||||
'loggedin' => $this->session->isLoggedIn(),
|
||||
'authbasic_autologin' => $this->getAuthBasicAutologinEnabled(),
|
||||
'pki_key' => $this->getPublicKey(),
|
||||
'pki_max_size' => CryptPKI::getMaxDataSize(),
|
||||
'import_allowed_mime' => ImportService::ALLOWED_MIME,
|
||||
'files_allowed_mime' => $this->configData->getFilesAllowedMime(),
|
||||
'session_timeout' => $this->configData->getSessionTimeout(),
|
||||
'csrf' => $this->getCSRF(),
|
||||
'pki_key' => $this->getPublicKey(),
|
||||
'pki_max_size' => CryptPKI::getMaxDataSize(),
|
||||
'import_allowed_mime' => ImportStrategy::ALLOWED_MIME,
|
||||
'files_allowed_mime' => $this->configData->getFilesAllowedMime(),
|
||||
'session_timeout' => $this->configData->getSessionTimeout(),
|
||||
'csrf' => $this->getCSRF(),
|
||||
];
|
||||
|
||||
return $this->returnJsonResponseData($data);
|
||||
@@ -107,7 +103,7 @@ final class GetEnvironmentController extends SimpleControllerBase
|
||||
*/
|
||||
private function getJsLang(): array
|
||||
{
|
||||
return require RESOURCES_PATH.DIRECTORY_SEPARATOR.'strings.js.inc';
|
||||
return require RESOURCES_PATH . DIRECTORY_SEPARATOR . 'strings.js.inc';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +135,7 @@ final class GetEnvironmentController extends SimpleControllerBase
|
||||
private function getPlugins(): array
|
||||
{
|
||||
try {
|
||||
return $this->pluginManager->getEnabledPlugins();
|
||||
return $this->pluginManagerService->getEnabled();
|
||||
} catch (Exception $e) {
|
||||
processException($e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user