Skip to content

Commit

Permalink
Fixing whitespaces on PHP files
Browse files Browse the repository at this point in the history
Signed-off-by: Azri Adam <[email protected]>
  • Loading branch information
azri-cs committed Nov 1, 2024
1 parent b58a73c commit 236e15d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 41 deletions.
13 changes: 5 additions & 8 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@
use OCP\IConfig;
use OCP\IRequest;

class SettingsController extends Controller
{
class SettingsController extends Controller {
public const ACCEPTED_KEYS = [
'workspace_enabled',
'is_full_width_editor'
];

public function __construct(
string $appName,
IRequest $request,
string $appName,
IRequest $request,
private IConfig $config,
private ?string $userId,
)
{
) {
parent::__construct($appName, $request);
}

Expand All @@ -37,8 +35,7 @@ public function __construct(
* @psalm-return DataResponse<200|400, array{workspace_enabled?: mixed, is_full_width_editor?: mixed, message?: 'Invalid config key'}, array<never, never>>
*/
#[NoAdminRequired]
public function updateConfig(string $key, int|string $value): DataResponse
{
public function updateConfig(string $key, int|string $value): DataResponse {
if (!in_array($key, self::ACCEPTED_KEYS, true)) {
return new DataResponse(['message' => 'Invalid config key'], Http::STATUS_BAD_REQUEST);
}
Expand Down
26 changes: 9 additions & 17 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,41 @@
use OCP\IAppConfig;
use OCP\IConfig;

class ConfigService
{
class ConfigService {
public function __construct(
private IAppConfig $appConfig,
private IConfig $config,
)
{
private IConfig $config,
) {
}

public function getDefaultFileExtension(): string
{
public function getDefaultFileExtension(): string {
return $this->appConfig->getValueString(Application::APP_NAME, 'default_file_extension', 'md');
}

public function isRichEditingEnabled(): bool
{
public function isRichEditingEnabled(): bool {
return ($this->appConfig->getValueString(Application::APP_NAME, 'rich_editing_enabled', '1') === '1');
}

public function isRichWorkspaceAvailable(): bool
{
public function isRichWorkspaceAvailable(): bool {
if ($this->config->getSystemValueBool('enable_non-accessible_features', true) === false) {
return false;
}
return $this->appConfig->getValueString(Application::APP_NAME, 'workspace_available', '1') === '1';
}

public function isRichWorkspaceEnabledForUser(?string $userId): bool
{
public function isRichWorkspaceEnabledForUser(?string $userId): bool {
if ($userId === null) {
return true;
}
return $this->config->getUserValue($userId, Application::APP_NAME, 'workspace_enabled', '1') === '1';
}

public function isNotifyPushSyncEnabled(): bool
{
public function isNotifyPushSyncEnabled(): bool {
return $this->appConfig->getValueBool(Application::APP_NAME, 'notify_push');

}

public function isFullWidthEditor(?string $userId): bool
{
public function isFullWidthEditor(?string $userId): bool {
return $this->config->getUserValue($userId, Application::APP_NAME, 'is_full_width_editor', '0') === '1';
}
}
26 changes: 10 additions & 16 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
use OCP\TaskProcessing\IManager;
use OCP\Translation\ITranslationManager;

class InitialStateProvider
{
class InitialStateProvider {
private const ASSISTANT_TASK_TYPES = [
'core:text2text',
'core:text2text:formalization',
Expand All @@ -24,17 +23,15 @@ class InitialStateProvider
];

public function __construct(
private IInitialState $initialState,
private ConfigService $configService,
private IInitialState $initialState,
private ConfigService $configService,
private ITranslationManager $translationManager,
private IManager $taskProcessingManager,
private ?string $userId,
)
{
private IManager $taskProcessingManager,
private ?string $userId,
) {
}

public function provideState(): void
{
public function provideState(): void {
$this->initialState->provideInitialState(
'workspace_available',
$this->configService->isRichWorkspaceAvailable()
Expand Down Expand Up @@ -87,18 +84,15 @@ public function provideState(): void
);
}

public function provideFileId(int $fileId): void
{
public function provideFileId(int $fileId): void {
$this->initialState->provideInitialState('file_id', $fileId);
}

public function provideFile(array $fileData): void
{
public function provideFile(array $fileData): void {
$this->initialState->provideInitialState('file', $fileData);
}

public function provideDirectEditToken(string $token): void
{
public function provideDirectEditToken(string $token): void {
$this->initialState->provideInitialState('directEditingToken', $token);
}
}

0 comments on commit 236e15d

Please sign in to comment.