Skip to content

Commit

Permalink
chore: Cleanup capabilities code
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Aug 24, 2023
1 parent fe0c503 commit 32f5879
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <[email protected]>
*
Expand Down Expand Up @@ -26,7 +28,6 @@
use OCA\Richdocuments\Service\CapabilitiesService;
use OCP\App\IAppManager;
use OCP\Capabilities\ICapability;
use OCP\IL10N;
use OCP\IURLGenerator;

class Capabilities implements ICapability {
Expand Down Expand Up @@ -66,7 +67,7 @@ class Capabilities implements ICapability {
'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
'application/vnd.ms-powerpoint.template.macroEnabled.12',
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
'text/csv'
'text/csv',
];

public const MIMETYPES_OPTIONAL = [
Expand Down Expand Up @@ -95,24 +96,16 @@ class Capabilities implements ICapability {
'application/pdf',
];

private IL10N $l10n;
private AppConfig $config;
private CapabilitiesService $capabilitiesService;
private PermissionManager $permissionManager;
private IURLGenerator $urlGenerator;
private IAppManager $appManager;
private ?string $userId = null;

private $capabilities = null;
private ?array $capabilities = null;

public function __construct(IL10N $l10n, AppConfig $config, CapabilitiesService $capabilitiesService, PermissionManager $permissionManager, IAppManager $appManager, ?string $userId, IURLGenerator $urlGenerator) {
$this->l10n = $l10n;
$this->config = $config;
$this->capabilitiesService = $capabilitiesService;
$this->permissionManager = $permissionManager;
$this->appManager = $appManager;
$this->userId = $userId;
$this->urlGenerator = $urlGenerator;
public function __construct(
private AppConfig $config,
private CapabilitiesService $capabilitiesService,
private PermissionManager $permissionManager,
private IAppManager $appManager,
private ?string $userId,
private IURLGenerator $urlGenerator
) {
}

public function getCapabilities() {
Expand Down Expand Up @@ -140,13 +133,13 @@ public function getCapabilities() {

$this->capabilities = [
'richdocuments' => [
'version' => \OC::$server->getAppManager()->getAppVersion('richdocuments'),
'version' => $this->appManager->getAppVersion('richdocuments'),
'mimetypes' => array_values($filteredMimetypes),
'mimetypesNoDefaultOpen' => array_values($optionalMimetypes),
'mimetypesSecureView' => $this->config->useSecureViewAdditionalMimes() ? self::SECURE_VIEW_ADDITIONAL_MIMES : [],
'collabora' => $collaboraCapabilities,
'direct_editing' => isset($collaboraCapabilities['hasMobileSupport']) ?: false,
'templates' => isset($collaboraCapabilities['hasTemplateSaveAs']) || isset($collaboraCapabilities['hasTemplateSource']) ?: false,
'direct_editing' => $collaboraCapabilities['hasMobileSupport'] ?? false,
'templates' => ($collaboraCapabilities['hasTemplateSaveAs'] ?? false) || ($collaboraCapabilities['hasTemplateSource'] ?? false),
'productName' => $this->capabilitiesService->getProductName(),
'editonline_endpoint' => $this->urlGenerator->linkToRouteAbsolute('richdocuments.document.editOnline'),
'config' => [
Expand Down

0 comments on commit 32f5879

Please sign in to comment.