-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
Signed-off-by: Julius Härtl <[email protected]> Signed-off-by: nextcloud-command <[email protected]>
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace OCA\Text\Service; | ||
|
||
use OCA\Text\AppInfo\Application; | ||
use OCP\IConfig; | ||
|
||
class ConfigService { | ||
private IConfig $config; | ||
|
||
public function __construct(IConfig $config) { | ||
$this->config = $config; | ||
} | ||
|
||
public function getDefaultFileExtension(): string { | ||
return $this->config->getAppValue(Application::APP_NAME, 'default_file_extension', 'md'); | ||
} | ||
|
||
public function isRichEditingEnabled(): bool { | ||
return ($this->config->getAppValue(Application::APP_NAME, 'rich_editing_enabled', '1') === '1'); | ||
} | ||
|
||
public function isRichWorkspaceAvailable(): bool { | ||
return $this->config->getAppValue(Application::APP_NAME, 'workspace_available', '1') === '1'; | ||
} | ||
|
||
public function isRichWorkspaceEnabledForUser(?string $userId): bool { | ||
if ($userId === null) { | ||
return true; | ||
} | ||
return $this->config->getUserValue($userId, Application::APP_NAME, 'workspace_enabled', '1') === '1'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace OCA\Text\Service; | ||
|
||
use OCP\AppFramework\Services\IInitialState; | ||
|
||
class InitialStateProvider { | ||
private IInitialState $initialState; | ||
private ConfigService $configService; | ||
private ?string $userId; | ||
|
||
public function __construct(IInitialState $initialState, ConfigService $configService, ?string $userId) { | ||
$this->initialState = $initialState; | ||
$this->configService = $configService; | ||
$this->userId = $userId; | ||
} | ||
|
||
public function provideState(): void { | ||
$this->initialState->provideInitialState( | ||
'workspace_available', | ||
$this->configService->isRichWorkspaceAvailable() | ||
); | ||
|
||
$this->initialState->provideInitialState( | ||
'workspace_enabled', | ||
$this->configService->isRichWorkspaceEnabledForUser($this->userId) | ||
); | ||
|
||
$this->initialState->provideInitialState( | ||
'default_file_extension', | ||
$this->configService->getDefaultFileExtension() | ||
); | ||
|
||
$this->initialState->provideInitialState( | ||
'rich_editing_enabled', | ||
$this->configService->isRichEditingEnabled() | ||
); | ||
} | ||
} |