diff --git a/app/modules/web/Controllers/Account/CopyPassController.php b/app/modules/web/Controllers/Account/CopyPassController.php index 6d820e28..63e7590b 100644 --- a/app/modules/web/Controllers/Account/CopyPassController.php +++ b/app/modules/web/Controllers/Account/CopyPassController.php @@ -47,7 +47,7 @@ final class CopyPassController extends AccountControllerBase Application $application, WebControllerHelper $webControllerHelper, AccountServiceInterface $accountService, - AccountPasswordHelper $accountPasswordHelper, + AccountPasswordHelper $accountPasswordHelper ) { parent::__construct( $application, diff --git a/app/modules/web/Controllers/Account/CopyPassHistoryController.php b/app/modules/web/Controllers/Account/CopyPassHistoryController.php index fa470771..38c05412 100644 --- a/app/modules/web/Controllers/Account/CopyPassHistoryController.php +++ b/app/modules/web/Controllers/Account/CopyPassHistoryController.php @@ -46,7 +46,7 @@ final class CopyPassHistoryController extends AccountControllerBase Application $application, WebControllerHelper $webControllerHelper, AccountServiceInterface $accountService, - AccountPasswordHelper $accountPasswordHelper, + AccountPasswordHelper $accountPasswordHelper ) { parent::__construct( $application, diff --git a/app/modules/web/Controllers/AuthToken/AuthTokenSaveBase.php b/app/modules/web/Controllers/AuthToken/AuthTokenSaveBase.php index 62e97253..0136dd5c 100644 --- a/app/modules/web/Controllers/AuthToken/AuthTokenSaveBase.php +++ b/app/modules/web/Controllers/AuthToken/AuthTokenSaveBase.php @@ -49,8 +49,7 @@ abstract class AuthTokenSaveBase extends ControllerBase Application $application, WebControllerHelper $webControllerHelper, AuthTokenServiceInterface $authTokenService, - CustomFieldServiceInterface $customFieldService, - + CustomFieldServiceInterface $customFieldService ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Controllers/ConfigLdap/CheckController.php b/app/modules/web/Controllers/ConfigLdap/CheckController.php index fcdc68ba..53ebcded 100644 --- a/app/modules/web/Controllers/ConfigLdap/CheckController.php +++ b/app/modules/web/Controllers/ConfigLdap/CheckController.php @@ -52,7 +52,7 @@ final class CheckController extends SimpleControllerBase Application $application, SimpleControllerHelper $simpleControllerHelper, LdapCheckServiceInterface $ldapCheckService, - TemplateInterface $template, + TemplateInterface $template ) { parent::__construct($application, $simpleControllerHelper); diff --git a/app/modules/web/Controllers/Install/InstallController.php b/app/modules/web/Controllers/Install/InstallController.php index 888264b7..67c34704 100644 --- a/app/modules/web/Controllers/Install/InstallController.php +++ b/app/modules/web/Controllers/Install/InstallController.php @@ -46,7 +46,7 @@ final class InstallController extends ControllerBase public function __construct( Application $application, WebControllerHelper $webControllerHelper, - InstallerServiceInterface $installer, + InstallerServiceInterface $installer ) { parent::__construct($application, $webControllerHelper); diff --git a/app/modules/web/Init.php b/app/modules/web/Init.php index f5bf77c0..cb9fcd48 100644 --- a/app/modules/web/Init.php +++ b/app/modules/web/Init.php @@ -247,9 +247,7 @@ final class Init extends HttpModuleBase // Recargar los permisos del perfil de usuario $this->context->setUserProfile( - $this->userProfileService - ->getById($this->context->getUserData()->getUserProfileId()) - ->getProfile() + $this->userProfileService->getById($this->context->getUserData()->getUserProfileId())->getProfile() ); } diff --git a/lib/SP/Core/Definitions/CoreDefinitions.php b/lib/SP/Core/Definitions/CoreDefinitions.php index 8b893027..3b635283 100644 --- a/lib/SP/Core/Definitions/CoreDefinitions.php +++ b/lib/SP/Core/Definitions/CoreDefinitions.php @@ -38,6 +38,7 @@ use SP\Core\Language; use SP\Core\LanguageInterface; use SP\Core\MimeTypes; use SP\Core\MimeTypesInterface; +use SP\Core\ProvidersHelper; use SP\Core\UI\Theme; use SP\Core\UI\ThemeInterface; use SP\Domain\Config\ConfigInterface; @@ -72,6 +73,7 @@ use SP\Providers\Auth\Ldap\Ldap; use SP\Providers\Auth\Ldap\LdapAuth; use SP\Providers\Auth\Ldap\LdapAuthInterface; use SP\Providers\Auth\Ldap\LdapParams; +use SP\Providers\Log\FileLogHandler; use SP\Providers\Mail\MailProvider; use SP\Providers\Mail\PhpMailerWrapper; use function DI\autowire; @@ -164,6 +166,15 @@ final class CoreDefinitions throw new SPException(__u('Unimplemented'), SPException::ERROR, __u('Wrong backend type')); }, + ProvidersHelper::class => static function (ContainerInterface $c) { + $configData = $c->get(ConfigDataInterface::class); + + if (!$configData->isInstalled()) { + return new ProvidersHelper($c->get(FileLogHandler::class)); + } + + return create(ProvidersHelper::class); + }, ]; } } \ No newline at end of file diff --git a/lib/SP/Core/ModuleBase.php b/lib/SP/Core/ModuleBase.php index f61d9439..2abc023d 100644 --- a/lib/SP/Core/ModuleBase.php +++ b/lib/SP/Core/ModuleBase.php @@ -4,7 +4,7 @@ * * @author nuxsmin * @link https://syspass.org - * @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org + * @copyright 2012-2022, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. * @@ -64,11 +64,11 @@ abstract class ModuleBase */ protected function initEventHandlers(bool $partialInit = false): void { - if (DEBUG || $this->configData->isDebug()) { + if (DEBUG || $this->configData->isDebug() || !$this->configData->isInstalled()) { $this->eventDispatcher->attach($this->providersHelper->getFileLogHandler()); } - if ($partialInit) { + if ($partialInit || !$this->configData->isInstalled()) { return; } diff --git a/lib/SP/Core/ProvidersHelper.php b/lib/SP/Core/ProvidersHelper.php index 070232a0..b27b06f6 100644 --- a/lib/SP/Core/ProvidersHelper.php +++ b/lib/SP/Core/ProvidersHelper.php @@ -32,39 +32,29 @@ use SP\Providers\Log\RemoteSyslogHandler; use SP\Providers\Log\SyslogHandler; use SP\Providers\Mail\MailHandler; use SP\Providers\Notification\NotificationHandler; +use SP\Providers\ProviderInterface; /** * The Provider helper class will have oll the providers availabe in the application */ final class ProvidersHelper { - private FileLogHandler $fileLogHandler; - private DatabaseLogHandler $databaseLogHandler; - private MailHandler $mailHandler; - private SyslogHandler $syslogHandler; - private RemoteSyslogHandler $remoteSyslogHandler; - private AclHandler $aclHandler; - private NotificationHandler $notificationHandler; + private FileLogHandler $fileLogHandler; + private ?DatabaseLogHandler $databaseLogHandler; + private ?MailHandler $mailHandler; + private ?SyslogHandler $syslogHandler; + private ?RemoteSyslogHandler $remoteSyslogHandler; + private ?AclHandler $aclHandler; + private ?NotificationHandler $notificationHandler; - /** - * Module constructor. - * - * @param \SP\Providers\Log\FileLogHandler $fileLogHandler - * @param \SP\Providers\Log\DatabaseLogHandler $databaseLogHandler - * @param \SP\Providers\Mail\MailHandler $mailHandler - * @param \SP\Providers\Log\SyslogHandler $syslogHandler - * @param \SP\Providers\Log\RemoteSyslogHandler $remoteSyslogHandler - * @param \SP\Providers\Acl\AclHandler $aclHandler - * @param \SP\Providers\Notification\NotificationHandler $notificationHandler - */ public function __construct( FileLogHandler $fileLogHandler, - DatabaseLogHandler $databaseLogHandler, - MailHandler $mailHandler, - SyslogHandler $syslogHandler, - RemoteSyslogHandler $remoteSyslogHandler, - AclHandler $aclHandler, - NotificationHandler $notificationHandler + ?DatabaseLogHandler $databaseLogHandler = null, + ?MailHandler $mailHandler = null, + ?SyslogHandler $syslogHandler = null, + ?RemoteSyslogHandler $remoteSyslogHandler = null, + ?AclHandler $aclHandler = null, + ?NotificationHandler $notificationHandler = null ) { $this->fileLogHandler = $fileLogHandler; $this->databaseLogHandler = $databaseLogHandler; @@ -75,86 +65,58 @@ final class ProvidersHelper $this->notificationHandler = $notificationHandler; } - /** - * @return \SP\Providers\Log\FileLogHandler - */ + private static function ensureIsInitialized(?ProviderInterface $provider = null): void + { + if ($provider !== null && !$provider->isInitialized()) { + $provider->initialize(); + } + } + public function getFileLogHandler(): FileLogHandler { - if (!$this->fileLogHandler->isInitialized()) { - $this->fileLogHandler->initialize(); - } + self::ensureIsInitialized($this->fileLogHandler); return $this->fileLogHandler; } - /** - * @return \SP\Providers\Log\DatabaseLogHandler - */ public function getDatabaseLogHandler(): DatabaseLogHandler { - if (!$this->databaseLogHandler->isInitialized()) { - $this->databaseLogHandler->initialize(); - } + self::ensureIsInitialized($this->databaseLogHandler); return $this->databaseLogHandler; } - /** - * @return \SP\Providers\Mail\MailHandler - */ public function getMailHandler(): MailHandler { - if (!$this->mailHandler->isInitialized()) { - $this->mailHandler->initialize(); - } + self::ensureIsInitialized($this->mailHandler); return $this->mailHandler; } - /** - * @return \SP\Providers\Log\SyslogHandler - */ public function getSyslogHandler(): SyslogHandler { - if (!$this->syslogHandler->isInitialized()) { - $this->syslogHandler->initialize(); - } + self::ensureIsInitialized($this->syslogHandler); return $this->syslogHandler; } - /** - * @return \SP\Providers\Log\RemoteSyslogHandler - */ public function getRemoteSyslogHandler(): RemoteSyslogHandler { - if (!$this->remoteSyslogHandler->isInitialized()) { - $this->remoteSyslogHandler->initialize(); - } + self::ensureIsInitialized($this->remoteSyslogHandler); return $this->remoteSyslogHandler; } - /** - * @return \SP\Providers\Acl\AclHandler - */ public function getAclHandler(): AclHandler { - if (!$this->aclHandler->isInitialized()) { - $this->aclHandler->initialize(); - } + self::ensureIsInitialized($this->aclHandler); return $this->aclHandler; } - /** - * @return \SP\Providers\Notification\NotificationHandler - */ public function getNotificationHandler(): NotificationHandler { - if (!$this->notificationHandler->isInitialized()) { - $this->notificationHandler->initialize(); - } + self::ensureIsInitialized($this->notificationHandler); return $this->notificationHandler; } diff --git a/lib/SP/Domain/Config/Adapters/ConfigData.php b/lib/SP/Domain/Config/Adapters/ConfigData.php index 8d45419f..beba6507 100644 --- a/lib/SP/Domain/Config/Adapters/ConfigData.php +++ b/lib/SP/Domain/Config/Adapters/ConfigData.php @@ -33,17 +33,17 @@ use SP\Domain\Config\In\ConfigDataInterface; */ final class ConfigData extends DataCollection implements JsonSerializable, ConfigDataInterface { - private const PUBLIC_LINK_MAX_VIEWS = 3; - private const PUBLIC_LINK_MAX_TIME = 600; - private const ACCOUNT_COUNT = 12; - private const DB_PORT = 3306; - private const FILES_ALLOWED_SIZE = 1024; - private const MAIL_PORT = 587; - private const SESSION_TIMEOUT = 300; - private const SITE_THEME = 'material-blue'; - private const SYSLOG_PORT = 514; - private const ACCOUNT_EXPIRE_TIME = 10368000; - private const PROXY_PORT = 8080; + private const DEFAULT_PUBLIC_LINK_MAX_VIEWS = 3; + private const DEFAULT_PUBLIC_LINK_MAX_TIME = 600; + private const DEFAULT_ACCOUNT_COUNT = 12; + private const DEFAULT_DB_PORT = 3306; + private const DEFAULT_FILES_ALLOWED_SIZE = 1024; + private const DEFAULT_MAIL_PORT = 587; + private const DEFAULT_SESSION_TIMEOUT = 300; + private const DEFAULT_SITE_THEME = 'material-blue'; + private const DEFAULT_SYSLOG_PORT = 514; + private const DEFAULT_ACCOUNT_EXPIRE_TIME = 10368000; + private const DEFAULT_PROXY_PORT = 8080; public function getAttributes(): array { @@ -52,188 +52,188 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getLogEvents(): array { - return $this->get('logEvents', []); + return $this->get(ConfigDataInterface::LOG_EVENTS, []); } public function setLogEvents(?array $logEvents): ConfigDataInterface { - $this->set('logEvents', $logEvents); + $this->set(ConfigDataInterface::LOG_EVENTS, $logEvents); return $this; } public function isDokuwikiEnabled(): bool { - return $this->get('dokuwikiEnabled', false); + return $this->get(ConfigDataInterface::DOKUWIKI_ENABLED, false); } public function setDokuwikiEnabled(?bool $dokuwikiEnabled): ConfigDataInterface { - $this->set('dokuwikiEnabled', (bool)$dokuwikiEnabled); + $this->set(ConfigDataInterface::DOKUWIKI_ENABLED, (bool)$dokuwikiEnabled); return $this; } public function getDokuwikiUrl(): ?string { - return $this->get('dokuwikiUrl'); + return $this->get(ConfigDataInterface::DOKUWIKI_URL); } public function setDokuwikiUrl(?string $dokuwikiUrl): ConfigDataInterface { - $this->set('dokuwikiUrl', $dokuwikiUrl); + $this->set(ConfigDataInterface::DOKUWIKI_URL, $dokuwikiUrl); return $this; } public function getDokuwikiUrlBase(): ?string { - return $this->get('dokuwikiUrlBase'); + return $this->get(ConfigDataInterface::DOKUWIKI_URL_BASE); } public function setDokuwikiUrlBase(?string $dokuwikiUrlBase): ConfigDataInterface { - $this->set('dokuwikiUrlBase', $dokuwikiUrlBase); + $this->set(ConfigDataInterface::DOKUWIKI_URL_BASE, $dokuwikiUrlBase); return $this; } public function getDokuwikiUser(): ?string { - return $this->get('dokuwikiUser'); + return $this->get(ConfigDataInterface::DOKUWIKI_USER); } public function setDokuwikiUser(?string $dokuwikiUser): ConfigDataInterface { - $this->set('dokuwikiUser', $dokuwikiUser); + $this->set(ConfigDataInterface::DOKUWIKI_USER, $dokuwikiUser); return $this; } public function getDokuwikiPass(): ?string { - return $this->get('dokuwikiPass'); + return $this->get(ConfigDataInterface::DOKUWIKI_PASS); } public function setDokuwikiPass(?string $dokuwikiPass): ConfigDataInterface { - $this->set('dokuwikiPass', $dokuwikiPass); + $this->set(ConfigDataInterface::DOKUWIKI_PASS, $dokuwikiPass); return $this; } public function getDokuwikiNamespace(): ?string { - return $this->get('dokuwikiNamespace'); + return $this->get(ConfigDataInterface::DOKUWIKI_NAMESPACE); } public function setDokuwikiNamespace(?string $dokuwikiNamespace): ConfigDataInterface { - $this->set('dokuwikiNamespace', $dokuwikiNamespace); + $this->set(ConfigDataInterface::DOKUWIKI_NAMESPACE, $dokuwikiNamespace); return $this; } public function getLdapDefaultGroup(): int { - return (int)$this->get('ldapDefaultGroup'); + return (int)$this->get(ConfigDataInterface::LDAP_DEFAULT_GROUP); } public function setLdapDefaultGroup(?int $ldapDefaultGroup): ConfigDataInterface { - $this->set('ldapDefaultGroup', (int)$ldapDefaultGroup); + $this->set(ConfigDataInterface::LDAP_DEFAULT_GROUP, (int)$ldapDefaultGroup); return $this; } public function getLdapDefaultProfile(): int { - return (int)$this->get('ldapDefaultProfile'); + return (int)$this->get(ConfigDataInterface::LDAP_DEFAULT_PROFILE); } public function setLdapDefaultProfile(?int $ldapDefaultProfile): ConfigDataInterface { - $this->set('ldapDefaultProfile', (int)$ldapDefaultProfile); + $this->set(ConfigDataInterface::LDAP_DEFAULT_PROFILE, (int)$ldapDefaultProfile); return $this; } public function isProxyEnabled(): bool { - return $this->get('proxyEnabled', false); + return $this->get(ConfigDataInterface::PROXY_ENABLED, false); } public function setProxyEnabled(?bool $proxyEnabled): ConfigDataInterface { - $this->set('proxyEnabled', (bool)$proxyEnabled); + $this->set(ConfigDataInterface::PROXY_ENABLED, (bool)$proxyEnabled); return $this; } public function getProxyServer(): ?string { - return $this->get('proxyServer'); + return $this->get(ConfigDataInterface::PROXY_SERVER); } public function setProxyServer(?string $proxyServer): ConfigDataInterface { - $this->set('proxyServer', $proxyServer); + $this->set(ConfigDataInterface::PROXY_SERVER, $proxyServer); return $this; } public function getProxyPort(): int { - return $this->get('proxyPort', self::PROXY_PORT); + return $this->get(ConfigDataInterface::PROXY_PORT, self::DEFAULT_PROXY_PORT); } public function setProxyPort(?int $proxyPort): ConfigDataInterface { - $this->set('proxyPort', (int)$proxyPort); + $this->set(ConfigDataInterface::PROXY_PORT, (int)$proxyPort); return $this; } public function getProxyUser(): ?string { - return $this->get('proxyUser'); + return $this->get(ConfigDataInterface::PROXY_USER); } public function setProxyUser(?string $proxyUser): ConfigDataInterface { - $this->set('proxyUser', $proxyUser); + $this->set(ConfigDataInterface::PROXY_USER, $proxyUser); return $this; } public function getProxyPass(): ?string { - return $this->get('proxyPass'); + return $this->get(ConfigDataInterface::PROXY_PASS); } public function setProxyPass(?string $proxyPass): ConfigDataInterface { - $this->set('proxyPass', $proxyPass); + $this->set(ConfigDataInterface::PROXY_PASS, $proxyPass); return $this; } public function getPublinksMaxViews(): int { - return $this->get('publinksMaxViews', self::PUBLIC_LINK_MAX_VIEWS); + return $this->get(ConfigDataInterface::PUBLINKS_MAX_VIEWS, self::DEFAULT_PUBLIC_LINK_MAX_VIEWS); } public function setPublinksMaxViews(?int $publinksMaxViews): ConfigDataInterface { - $this->set('publinksMaxViews', (int)$publinksMaxViews); + $this->set(ConfigDataInterface::PUBLINKS_MAX_VIEWS, (int)$publinksMaxViews); return $this; } public function getPublinksMaxTime(): int { - return $this->get('publinksMaxTime', self::PUBLIC_LINK_MAX_TIME); + return $this->get('publinksMaxTime', self::DEFAULT_PUBLIC_LINK_MAX_TIME); } public function setPublinksMaxTime(?int $publinksMaxTime): ConfigDataInterface @@ -281,7 +281,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getSyslogPort(): int { - return $this->get('syslogPort', self::SYSLOG_PORT); + return $this->get('syslogPort', self::DEFAULT_SYSLOG_PORT); } public function setSyslogPort(?int $syslogPort): ConfigDataInterface @@ -329,7 +329,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getAccountCount(): int { - return $this->get('accountCount', self::ACCOUNT_COUNT); + return $this->get('accountCount', self::DEFAULT_ACCOUNT_COUNT); } public function setAccountCount(?int $accountCount): ConfigDataInterface @@ -457,7 +457,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getFilesAllowedSize(): int { - return $this->get('filesAllowedSize', self::FILES_ALLOWED_SIZE); + return $this->get('filesAllowedSize', self::DEFAULT_FILES_ALLOWED_SIZE); } public function setFilesAllowedSize(?int $filesAllowedSize): ConfigDataInterface @@ -613,7 +613,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getMailPort(): int { - return $this->get('mailPort', self::MAIL_PORT); + return $this->get('mailPort', self::DEFAULT_MAIL_PORT); } public function setMailPort(?int $mailPort): ConfigDataInterface @@ -709,7 +709,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getSessionTimeout(): int { - return $this->get('sessionTimeout', self::SESSION_TIMEOUT); + return $this->get('sessionTimeout', self::DEFAULT_SESSION_TIMEOUT); } public function setSessionTimeout(?int $sessionTimeout): ConfigDataInterface @@ -733,7 +733,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getSiteTheme(): string { - return $this->get('siteTheme', self::SITE_THEME); + return $this->get('siteTheme', self::DEFAULT_SITE_THEME); } public function setSiteTheme(?string $siteTheme): ConfigDataInterface @@ -877,7 +877,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getDbPort(): int { - return $this->get('dbPort', self::DB_PORT); + return $this->get('dbPort', self::DEFAULT_DB_PORT); } public function setDbPort(?int $dbPort): ConfigDataInterface @@ -1088,7 +1088,7 @@ final class ConfigData extends DataCollection implements JsonSerializable, Confi public function getAccountExpireTime(): int { - return $this->get('accountExpireTime', self::ACCOUNT_EXPIRE_TIME); + return $this->get('accountExpireTime', self::DEFAULT_ACCOUNT_EXPIRE_TIME); } public function setAccountExpireTime(?int $accountExpireTime): ConfigDataInterface diff --git a/lib/SP/Domain/Config/In/ConfigDataInterface.php b/lib/SP/Domain/Config/In/ConfigDataInterface.php index 7913d8c9..07b031e4 100644 --- a/lib/SP/Domain/Config/In/ConfigDataInterface.php +++ b/lib/SP/Domain/Config/In/ConfigDataInterface.php @@ -26,1165 +26,409 @@ namespace SP\Domain\Config\In; /** - * Class configData - * - * @package SP\Config + * Interface ConfigDataInterface */ interface ConfigDataInterface { - /** - * @return array - */ + public const LOG_EVENTS = 'logEvents'; + public const DOKUWIKI_ENABLED = 'dokuwikiEnabled'; + public const DOKUWIKI_URL = 'dokuwikiUrl'; + public const DOKUWIKI_URL_BASE = 'dokuwikiUrlBase'; + public const DOKUWIKI_USER = 'dokuwikiUser'; + public const DOKUWIKI_PASS = 'dokuwikiPass'; + public const DOKUWIKI_NAMESPACE = 'dokuwikiNamespace'; + public const LDAP_DEFAULT_GROUP = 'ldapDefaultGroup'; + public const LDAP_DEFAULT_PROFILE = 'ldapDefaultProfile'; + public const PROXY_ENABLED = 'proxyEnabled'; + public const PROXY_SERVER = 'proxyServer'; + public const PROXY_PORT = 'proxyPort'; + public const PROXY_USER = 'proxyUser'; + public const PROXY_PASS = 'proxyPass'; + public const PUBLINKS_MAX_VIEWS = 'publinksMaxViews'; + public function getAttributes(): array; - /** - * @return array - */ public function getLogEvents(): array; - /** - * @param array|null $logEvents - * - * @return ConfigDataInterface - */ public function setLogEvents(?array $logEvents): ConfigDataInterface; - /** - * @return boolean - */ public function isDokuwikiEnabled(): bool; - /** - * @param bool|null $dokuwikiEnabled - * - * @return $this - */ public function setDokuwikiEnabled(?bool $dokuwikiEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getDokuwikiUrl(): ?string; - /** - * @param string|null $dokuwikiUrl - * - * @return $this - */ public function setDokuwikiUrl(?string $dokuwikiUrl): ConfigDataInterface; - /** - * @return string|null - */ public function getDokuwikiUrlBase(): ?string; - /** - * @param string|null $dokuwikiUrlBase - * - * @return $this - */ public function setDokuwikiUrlBase(?string $dokuwikiUrlBase): ConfigDataInterface; - /** - * @return string|null - */ public function getDokuwikiUser(): ?string; - /** - * @param string|null $dokuwikiUser - * - * @return $this - */ public function setDokuwikiUser(?string $dokuwikiUser): ConfigDataInterface; - /** - * @return string|null - */ public function getDokuwikiPass(): ?string; - /** - * @param string|null $dokuwikiPass - * - * @return $this - */ public function setDokuwikiPass(?string $dokuwikiPass): ConfigDataInterface; - /** - * @return string|null - */ public function getDokuwikiNamespace(): ?string; - /** - * @param string|null $dokuwikiNamespace - * - * @return $this - */ public function setDokuwikiNamespace(?string $dokuwikiNamespace): ConfigDataInterface; - /** - * @return int - */ public function getLdapDefaultGroup(): int; - /** - * @param int|null $ldapDefaultGroup - * - * @return $this - */ public function setLdapDefaultGroup(?int $ldapDefaultGroup): ConfigDataInterface; - /** - * @return int - */ public function getLdapDefaultProfile(): int; - /** - * @param int|null $ldapDefaultProfile - * - * @return $this - */ public function setLdapDefaultProfile(?int $ldapDefaultProfile): ConfigDataInterface; - /** - * @return boolean - */ public function isProxyEnabled(): bool; - /** - * @param boolean|null $proxyEnabled - * - * @return $this - */ public function setProxyEnabled(?bool $proxyEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getProxyServer(): ?string; - /** - * @param string|null $proxyServer - * - * @return $this - */ public function setProxyServer(?string $proxyServer): ConfigDataInterface; - /** - * @return int - */ public function getProxyPort(): int; - /** - * @param int|null $proxyPort - * - * @return $this - */ public function setProxyPort(?int $proxyPort): ConfigDataInterface; - /** - * @return string|null - */ public function getProxyUser(): ?string; - /** - * @param string|null $proxyUser - * - * @return $this - */ public function setProxyUser(?string $proxyUser): ConfigDataInterface; - /** - * @return string|null - */ public function getProxyPass(): ?string; - /** - * @param string|null $proxyPass - * - * @return $this - */ public function setProxyPass(?string $proxyPass): ConfigDataInterface; - /** - * @return int - */ public function getPublinksMaxViews(): int; - /** - * @param int|null $publinksMaxViews - * - * @return $this - */ public function setPublinksMaxViews(?int $publinksMaxViews): ConfigDataInterface; - /** - * @return int - */ public function getPublinksMaxTime(): int; - /** - * @param int|null $publinksMaxTime - * - * @return $this - */ public function setPublinksMaxTime(?int $publinksMaxTime): ConfigDataInterface; - /** - * @return boolean - */ public function isSyslogEnabled(): bool; - /** - * @param boolean|null $syslogEnabled - * - * @return $this - */ public function setSyslogEnabled(?bool $syslogEnabled): ConfigDataInterface; - /** - * @return boolean - */ public function isSyslogRemoteEnabled(): bool; - /** - * @param boolean|null $syslogRemoteEnabled - * - * @return $this - */ public function setSyslogRemoteEnabled(?bool $syslogRemoteEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getSyslogServer(): ?string; - /** - * @param string|null $syslogServer - * - * @return $this - */ public function setSyslogServer(?string $syslogServer): ConfigDataInterface; - /** - * @return int - */ public function getSyslogPort(): int; - /** - * @param int|null $syslogPort - * - * @return $this - */ public function setSyslogPort(?int $syslogPort): ConfigDataInterface; - /** - * @return string|null - */ public function getBackupHash(): ?string; - /** - * @param string|null $backup_hash - * - * @return $this - */ public function setBackupHash(?string $backup_hash): ConfigDataInterface; - /** - * @return string|null - */ public function getExportHash(): ?string; - /** - * @param string|null $export_hash - * - * @return $this - */ public function setExportHash(?string $export_hash): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapBindUser(): ?string; - /** - * @param string|null $ldapBindUser - * - * @return $this - */ public function setLdapBindUser(?string $ldapBindUser): ConfigDataInterface; - /** - * @return int - */ public function getAccountCount(): int; - /** - * @param int|null $accountCount - * - * @return $this - */ public function setAccountCount(?int $accountCount): ConfigDataInterface; - /** - * @return boolean - */ public function isAccountLink(): bool; - /** - * @param bool|null $accountLink - * - * @return $this - */ public function setAccountLink(?bool $accountLink): ConfigDataInterface; - /** - * @return bool - */ public function isCheckUpdates(): bool; - /** - * @param bool|null $checkUpdates - * - * @return $this - */ public function setCheckUpdates(?bool $checkUpdates): ConfigDataInterface; - /** - * @return string|null - */ public function getConfigHash(): ?string; - /** - * Generates a hash from current config options - */ public function setConfigHash(): ConfigDataInterface; - /** - * @return string|null - */ public function getDbHost(): ?string; - /** - * @param string|null $dbHost - * - * @return $this - */ public function setDbHost(?string $dbHost): ConfigDataInterface; - /** - * @return string|null - */ public function getDbName(): ?string; - /** - * @param string|null $dbName - * - * @return $this - */ public function setDbName(?string $dbName): ConfigDataInterface; - /** - * @return string|null - */ public function getDbPass(): ?string; - /** - * @param string|null $dbPass - * - * @return $this - */ public function setDbPass(?string $dbPass): ConfigDataInterface; - /** - * @return string|null - */ public function getDbUser(): ?string; - /** - * @param string|null $dbUser - * - * @return $this - */ public function setDbUser(?string $dbUser): ConfigDataInterface; - /** - * @return bool - */ public function isDebug(): bool; - /** - * @param bool|null $debug - * - * @return $this - */ public function setDebug(?bool $debug): ConfigDataInterface; - /** - * @return bool - */ public function isDemoEnabled(): bool; - /** - * @param bool|null $demoEnabled - * - * @return $this - */ public function setDemoEnabled(?bool $demoEnabled): ConfigDataInterface; - /** - * @return array - */ public function getFilesAllowedExts(): array; - /** - * @return int - */ public function getFilesAllowedSize(): int; - /** - * @param int|null $filesAllowedSize - * - * @return $this - */ public function setFilesAllowedSize(?int $filesAllowedSize): ConfigDataInterface; - /** - * @return bool - */ public function isFilesEnabled(): bool; - /** - * @param bool|null $filesEnabled - * - * @return $this - */ public function setFilesEnabled(?bool $filesEnabled): ConfigDataInterface; - /** - * @return bool - */ public function isGlobalSearch(): bool; - /** - * @param bool|null $globalSearch - * - * @return $this - */ public function setGlobalSearch(?bool $globalSearch): ConfigDataInterface; - /** - * @return bool - */ public function isInstalled(): bool; - /** - * @param bool|null $installed - * - * @return $this - */ public function setInstalled(?bool $installed): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapBase(): ?string; - /** - * @param string|null $ldapBase - * - * @return $this - */ public function setLdapBase(?string $ldapBase): ConfigDataInterface; - /** - * @return bool - */ public function isLdapEnabled(): bool; - /** - * @param bool|null $ldapEnabled - * - * @return $this - */ public function setLdapEnabled(?bool $ldapEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapGroup(): ?string; - /** - * @param string|null $ldapGroup - * - * @return $this - */ public function setLdapGroup(?string $ldapGroup): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapServer(): ?string; - /** - * @param string|null $ldapServer - * - * @return $this - */ public function setLdapServer(?string $ldapServer): ConfigDataInterface; - /** - * @return bool - */ public function isLogEnabled(): bool; - /** - * @param bool|null $logEnabled - * - * @return $this - */ public function setLogEnabled(?bool $logEnabled): ConfigDataInterface; - /** - * @return bool - */ public function isMailAuthenabled(): bool; - /** - * @param bool|null $mailAuthenabled - * - * @return $this - */ public function setMailAuthenabled(?bool $mailAuthenabled): ConfigDataInterface; - /** - * @return bool - */ public function isMailEnabled(): bool; - /** - * @param bool|null $mailEnabled - * - * @return $this - */ public function setMailEnabled(?bool $mailEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getMailFrom(): ?string; - /** - * @param string|null $mailFrom - * - * @return $this - */ public function setMailFrom(?string $mailFrom): ConfigDataInterface; - /** - * @return string|null - */ public function getMailPass(): ?string; - /** - * @param string|null $mailPass - * - * @return $this - */ public function setMailPass(?string $mailPass): ConfigDataInterface; - /** - * @return int - */ public function getMailPort(): int; - /** - * @param int|null $mailPort - * - * @return $this - */ public function setMailPort(?int $mailPort): ConfigDataInterface; - /** - * @return bool - */ public function isMailRequestsEnabled(): bool; - /** - * @param bool|null $mailRequestsEnabled - * - * @return $this - */ public function setMailRequestsEnabled(?bool $mailRequestsEnabled): ConfigDataInterface; - /** - * @return string|null - */ public function getMailSecurity(): ?string; - /** - * @param string|null $mailSecurity - * - * @return $this - */ public function setMailSecurity(?string $mailSecurity): ConfigDataInterface; - /** - * @return string|null - */ public function getMailServer(): ?string; - /** - * @param string|null $mailServer - * - * @return $this - */ public function setMailServer(?string $mailServer): ConfigDataInterface; - /** - * @return string|null - */ public function getMailUser(): ?string; - /** - * @param string|null $mailUser - * - * @return $this - */ public function setMailUser(?string $mailUser): ConfigDataInterface; - /** - * @return bool - */ public function isMaintenance(): bool; - /** - * @param bool|null $maintenance - * - * @return $this - */ public function setMaintenance(?bool $maintenance): ConfigDataInterface; - /** - * @return string|null - */ public function getPasswordSalt(): ?string; - /** - * @param string|null $passwordSalt - * - * @return $this - */ public function setPasswordSalt(?string $passwordSalt): ConfigDataInterface; - /** - * @return bool - */ public function isResultsAsCards(): bool; - /** - * @param bool|null $resultsAsCards - * - * @return $this - */ public function setResultsAsCards(?bool $resultsAsCards): ConfigDataInterface; - /** - * @return int - */ public function getSessionTimeout(): int; - /** - * @param int|null $sessionTimeout - * - * @return $this - */ public function setSessionTimeout(?int $sessionTimeout): ConfigDataInterface; - /** - * @return string|null - */ public function getSiteLang(): ?string; - /** - * @param string|null $siteLang - * - * @return $this - */ public function setSiteLang(?string $siteLang): ConfigDataInterface; - /** - * @return string - */ public function getSiteTheme(): string; - /** - * @param string|null $siteTheme - * - * @return $this - */ public function setSiteTheme(?string $siteTheme): ConfigDataInterface; - /** - * @return string|null - */ public function getConfigVersion(): ?string; - /** - * @param string|null $configVersion - * - * @return $this - */ public function setConfigVersion(?string $configVersion): ConfigDataInterface; - /** - * @return bool - */ public function isWikiEnabled(): bool; - /** - * @param bool|null $wikiEnabled - * - * @return $this - */ public function setWikiEnabled(?bool $wikiEnabled): ConfigDataInterface; - /** - * @return array - */ public function getWikiFilter(): array; - /** - * @param array|null $wikiFilter - * - * @return $this - */ public function setWikiFilter(?array $wikiFilter): ConfigDataInterface; - /** - * @return string|null - */ public function getWikiPageurl(): ?string; - /** - * @param string|null $wikiPageurl - * - * @return $this - */ public function setWikiPageurl(?string $wikiPageurl): ConfigDataInterface; - /** - * @return string|null - */ public function getWikiSearchurl(): ?string; - /** - * @param string|null $wikiSearchurl - * - * @return $this - */ public function setWikiSearchurl(?string $wikiSearchurl): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapBindPass(): ?string; - /** - * @param string|null $ldapBindPass - * - * @return $this - */ public function setLdapBindPass(?string $ldapBindPass): ConfigDataInterface; - /** - * @return bool - */ public function isPublinksImageEnabled(): bool; - /** - * @param bool|null $publinksImageEnabled - * - * @return $this - */ public function setPublinksImageEnabled(?bool $publinksImageEnabled): ConfigDataInterface; - /** - * @return bool - */ public function isHttpsEnabled(): bool; - /** - * @param bool|null $httpsEnabled - * - * @return $this - */ public function setHttpsEnabled(?bool $httpsEnabled): ConfigDataInterface; - /** - * @return bool - */ public function isCheckNotices(): bool; - /** - * @param bool|null $checknotices - * - * @return $this - */ public function setCheckNotices(?bool $checknotices): ConfigDataInterface; - /** - * @return bool - */ public function isAccountPassToImage(): bool; - /** - * @param bool|null $accountPassToImage - * - * @return $this - */ public function setAccountPassToImage(?bool $accountPassToImage): ConfigDataInterface; - /** - * @return string|null - */ public function getUpgradeKey(): ?string; - /** - * @param string|null $upgradeKey - * - * @return $this - */ public function setUpgradeKey(?string $upgradeKey): ConfigDataInterface; - /** - * @return int - */ public function getDbPort(): int; - /** - * @param int|null $dbPort - * - * @return $this - */ public function setDbPort(?int $dbPort): ConfigDataInterface; - /** - * @return bool - */ public function isPublinksEnabled(): bool; - /** - * @param bool|null $publinksEnabled - * - * @return $this - */ public function setPublinksEnabled(?bool $publinksEnabled): ConfigDataInterface; - /** - * Specify data which should be serialized to JSON - * - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php - * @return mixed data which can be serialized by json_encode, - * which is a value of any type other than a resource. - * @since 5.4.0 - */ public function jsonSerialize(); - /** - * @return string|null - */ public function getConfigSaver(): ?string; - /** - * @param string|null $configSaver - * - * @return $this - */ public function setConfigSaver(?string $configSaver): ConfigDataInterface; - /** - * @return string|null - */ public function getDbSocket(): ?string; - /** - * @param string|null $dbSocket - * - * @return ConfigDataInterface - */ public function setDbSocket(?string $dbSocket): ConfigDataInterface; - /** - * @return bool - */ public function isEncryptSession(): bool; - /** - * @param bool|null $encryptSession - * - * @return $this - */ public function setEncryptSession(?bool $encryptSession): ConfigDataInterface; - /** - * @return bool - */ public function isAccountFullGroupAccess(): bool; - /** - * @param bool|null $accountFullGroupAccess - * - * @return $this - */ public function setAccountFullGroupAccess(?bool $accountFullGroupAccess): ConfigDataInterface; - /** - * @return bool - */ public function isAuthBasicEnabled(): bool; - /** - * @param bool|null $authBasicEnabled - */ public function setAuthBasicEnabled(?bool $authBasicEnabled); - /** - * @return string|null - */ public function getAuthBasicDomain(): ?string; - /** - * @param string|null $authBasicDomain - * - * @return ConfigDataInterface - */ public function setAuthBasicDomain(?string $authBasicDomain): ConfigDataInterface; - /** - * @return bool - */ public function isAuthBasicAutoLoginEnabled(): bool; - /** - * @param bool|null $authBasicAutoLoginEnabled - * - * @return ConfigDataInterface - */ public function setAuthBasicAutoLoginEnabled(?bool $authBasicAutoLoginEnabled): ConfigDataInterface; - /** - * @return int|null - */ public function getSsoDefaultGroup(): ?int; - /** - * @param int|null $ssoDefaultGroup - * - * @return ConfigDataInterface - */ public function setSsoDefaultGroup(?int $ssoDefaultGroup): ConfigDataInterface; - /** - * @return int|null - */ public function getSsoDefaultProfile(): ?int; - /** - * @param int|null $ssoDefaultProfile - * - * @return ConfigDataInterface - */ public function setSsoDefaultProfile(?int $ssoDefaultProfile): ConfigDataInterface; - /** - * @return array|null - */ public function getMailRecipients(): ?array; - /** - * @param array|null $mailRecipients - * - * @return ConfigDataInterface - */ public function setMailRecipients(?array $mailRecipients): ConfigDataInterface; - /** - * @return array|null - */ public function getMailEvents(): ?array; - /** - * @param array|null $mailEvents - * - * @return ConfigDataInterface - */ public function setMailEvents(?array $mailEvents): ConfigDataInterface; - /** - * @return string - */ public function getDatabaseVersion(): string; - /** - * @param string|null $databaseVersion - * - * @return ConfigDataInterface - */ public function setDatabaseVersion(?string $databaseVersion): ConfigDataInterface; - /** - * @return int - */ public function getConfigDate(): int; - /** - * @param int $configDate - * - * @return $this - */ public function setConfigDate(int $configDate): ConfigDataInterface; - /** - * @return bool - */ public function isAccountExpireEnabled(): bool; - /** - * @param bool|null $accountExpireEnabled - * - * @return ConfigDataInterface - */ public function setAccountExpireEnabled(?bool $accountExpireEnabled): ConfigDataInterface; - /** - * @return int - */ public function getAccountExpireTime(): int; - /** - * @param int|null $accountExpireTime - * - * @return ConfigDataInterface - */ public function setAccountExpireTime(?int $accountExpireTime): ConfigDataInterface; - /** - * @return bool - */ public function isLdapTlsEnabled(): bool; - /** - * @param bool|null $ldapTlsEnabled - * - * @return ConfigDataInterface - */ public function setLdapTlsEnabled(?bool $ldapTlsEnabled): ConfigDataInterface; - /** - * @return array - */ public function getFilesAllowedMime(): array; - /** - * @param array|null $filesAllowedMime - * - * @return ConfigDataInterface - */ public function setFilesAllowedMime(?array $filesAllowedMime): ConfigDataInterface; - /** - * @return int - */ public function getLdapType(): int; - /** - * @param int|null $ldapType - * - * @return ConfigDataInterface - */ public function setLdapType(?int $ldapType): ConfigDataInterface; - /** - * @return string - */ public function getAppVersion(): string; - /** - * @param string|null $appVersion - * - * @return ConfigDataInterface - */ public function setAppVersion(?string $appVersion): ConfigDataInterface; - /** - * @return string|null - */ public function getApplicationUrl(): ?string; - /** - * @param string|null $applicationUrl - * - * @return ConfigDataInterface - */ public function setApplicationUrl(?string $applicationUrl): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapFilterUserObject(): ?string; - /** - * @param string|null $filter - * - * @return ConfigDataInterface - */ public function setLdapFilterUserObject(?string $filter): ConfigDataInterface; - /** - * @return string|null - */ public function getLdapFilterGroupObject(): ?string; - /** - * @param string|null $filter - * - * @return ConfigDataInterface - */ public function setLdapFilterGroupObject(?string $filter): ConfigDataInterface; - /** - * @return array - */ public function getLdapFilterUserAttributes(): array; - /** - * @param array|null $attributes - * - * @return ConfigDataInterface - */ public function setLdapFilterUserAttributes(?array $attributes): ConfigDataInterface; - /** - * @return array - */ public function getLdapFilterGroupAttributes(): array; - /** - * @param array|null $attributes - * - * @return ConfigDataInterface - */ public function setLdapFilterGroupAttributes(?array $attributes): ConfigDataInterface; - /** - * @return bool - */ public function isLdapDatabaseEnabled(): bool; - /** - * @param bool|null $ldapDatabaseEnabled - * - * @return ConfigDataInterface - */ public function setLdapDatabaseEnabled(?bool $ldapDatabaseEnabled): ConfigDataInterface; } \ No newline at end of file diff --git a/lib/SP/Domain/Config/Services/ConfigFileService.php b/lib/SP/Domain/Config/Services/ConfigFileService.php index 447dd52a..26e8e193 100644 --- a/lib/SP/Domain/Config/Services/ConfigFileService.php +++ b/lib/SP/Domain/Config/Services/ConfigFileService.php @@ -176,10 +176,8 @@ class ConfigFileService implements ConfigInterface * @return ConfigInterface * @throws \SP\Infrastructure\File\FileException */ - public function saveConfig( - ConfigDataInterface $configData, - ?bool $backup = true - ): ConfigInterface { + public function saveConfig(ConfigDataInterface $configData, ?bool $backup = true): ConfigInterface + { if ($backup) { $this->configBackupService->backup($configData); } diff --git a/lib/SP/Infrastructure/Database/DatabaseConnectionData.php b/lib/SP/Infrastructure/Database/DatabaseConnectionData.php index 5b7b387a..4735cd3c 100644 --- a/lib/SP/Infrastructure/Database/DatabaseConnectionData.php +++ b/lib/SP/Infrastructure/Database/DatabaseConnectionData.php @@ -43,12 +43,12 @@ final class DatabaseConnectionData public static function getFromConfig(ConfigDataInterface $configData): DatabaseConnectionData { return (new self()) - ->setDbHost($configData->getDbHost()) - ->setDbName($configData->getDbName()) - ->setDbUser($configData->getDbUser()) - ->setDbPass($configData->getDbPass()) - ->setDbPort($configData->getDbPort()) - ->setDbSocket($configData->getDbSocket()); + ->setDbHost($configData->getDbHost() ?? '') + ->setDbName($configData->getDbName() ?? '') + ->setDbUser($configData->getDbUser() ?? '') + ->setDbPass($configData->getDbPass() ?? '') + ->setDbPort($configData->getDbPort() ?? 0) + ->setDbSocket($configData->getDbSocket() ?? ''); } public function refreshFromConfig(ConfigDataInterface $configData): DatabaseConnectionData