diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9bebc8e..b346242 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -45,11 +45,6 @@ class Application extends App implements IBootstrap { 'share' => 1, ]; - /** - * Constructor - * - * @param array $urlParams - */ public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); diff --git a/lib/Command/CleanupSpacedeck.php b/lib/Command/CleanupSpacedeck.php index 3ee841e..dd3c940 100644 --- a/lib/Command/CleanupSpacedeck.php +++ b/lib/Command/CleanupSpacedeck.php @@ -23,7 +23,6 @@ class CleanupSpacedeck extends Command { - protected $output; /** * @var SessionService */ @@ -32,14 +31,18 @@ class CleanupSpacedeck extends Command { * @var SpacedeckAPIService */ private $apiService; + /** + * @var IConfig + */ + private $config; public function __construct(SpacedeckAPIService $apiService, SessionService $sessionService, IConfig $config) { parent::__construct(); - $this->config = $config; $this->sessionService = $sessionService; $this->apiService = $apiService; + $this->config = $config; } protected function configure() { diff --git a/lib/Controller/ConfigController.php b/lib/Controller/ConfigController.php index beeb341..3ad9721 100644 --- a/lib/Controller/ConfigController.php +++ b/lib/Controller/ConfigController.php @@ -15,10 +15,7 @@ use Psr\Log\LoggerInterface; use OCP\IRequest; -use OCP\AppFramework\Http; -use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Controller; use OCA\Spacedeck\Service\SpacedeckAPIService; @@ -26,10 +23,7 @@ class ConfigController extends Controller { - - private $userId; private $config; - private $dbtype; public function __construct($AppName, IRequest $request, @@ -39,7 +33,6 @@ public function __construct($AppName, ?string $userId) { parent::__construct($AppName, $request); $this->appName = $AppName; - $this->userId = $userId; $this->config = $config; $this->logger = $logger; $this->spacedeckAPIService = $spacedeckAPIService; diff --git a/lib/Controller/SessionController.php b/lib/Controller/SessionController.php index a3f8297..fa1b89a 100644 --- a/lib/Controller/SessionController.php +++ b/lib/Controller/SessionController.php @@ -17,13 +17,9 @@ use OCP\IRequest; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Controller; -use OCA\Spacedeck\AppInfo\Application; - class SessionController extends Controller { /** diff --git a/lib/Controller/SpacedeckAPIController.php b/lib/Controller/SpacedeckAPIController.php index 995f6f4..a1d9762 100644 --- a/lib/Controller/SpacedeckAPIController.php +++ b/lib/Controller/SpacedeckAPIController.php @@ -28,8 +28,7 @@ use OCA\Spacedeck\Service\SpacedeckAPIService; use OCA\Spacedeck\AppInfo\Application; -if (!function_exists('getallheaders')) -{ +if (!function_exists('getallheaders')) { // polyfill, e.g. on PHP 7.2 setups with nginx. // Can be removed when 7.2 becomes unsupported function getallheaders() { diff --git a/lib/Migration/CopySpacedeckAppData.php b/lib/Migration/CopySpacedeckAppData.php index d73483c..e2753d3 100644 --- a/lib/Migration/CopySpacedeckAppData.php +++ b/lib/Migration/CopySpacedeckAppData.php @@ -21,23 +21,35 @@ namespace OCA\Spacedeck\Migration; +use Exception; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\ILogger; use OCP\IConfig; use OCA\Spacedeck\AppInfo\Application; use OCA\Spacedeck\Service\SpacedeckBundleService; +use Psr\Log\LoggerInterface; +use Throwable; class CopySpacedeckAppData implements IRepairStep { - protected $logger; - private $customMimetypeMapping; + /** + * @var LoggerInterface + */ + private $logger; + /** + * @var SpacedeckBundleService + */ + private $bundleService; + /** + * @var IConfig + */ + private $config; - public function __construct(ILogger $logger, - SpacedeckBundleService $service, + public function __construct(LoggerInterface $logger, + SpacedeckBundleService $bundleService, IConfig $config) { $this->logger = $logger; - $this->service = $service; + $this->bundleService = $bundleService; $this->config = $config; } @@ -48,14 +60,14 @@ public function getName() { public function run(IOutput $output) { $this->logger->info('Copying Spacedeck data...'); - $this->service->killSpacedeck(); + $this->bundleService->killSpacedeck(); try { - $this->service->copySpacedeckData(); + $this->bundleService->copySpacedeckData(); $this->config->setAppValue(Application::APP_ID, 'spacedeck_data_copied', '1'); - $this->logger->info('Spacedeck data successfully copied!'); + $this->logger->info('Spacedeck data successfully copied!', ['app' => Application::APP_ID]); } catch (Exception | Throwable $e) { $this->config->setAppValue(Application::APP_ID, 'spacedeck_data_copied', '0'); - $this->logger->warning('Impossible to copy Spacedeck data'); + $this->logger->warning('Impossible to copy Spacedeck data', ['app' => Application::APP_ID]); } } -} \ No newline at end of file +} diff --git a/lib/Migration/RegisterMimeType.php b/lib/Migration/RegisterMimeType.php index 448f4dc..57710aa 100644 --- a/lib/Migration/RegisterMimeType.php +++ b/lib/Migration/RegisterMimeType.php @@ -21,15 +21,19 @@ namespace OCA\Spacedeck\Migration; +use OCA\Spacedeck\AppInfo\Application; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class RegisterMimeType implements IRepairStep { - protected $logger; - private $customMimetypeMapping; - public function __construct(ILogger $logger) { + /** + * @var LoggerInterface + */ + private $logger; + + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } @@ -38,7 +42,7 @@ public function getName() { } public function run(IOutput $output) { - $this->logger->info('Registering the Spacedeck mimetype...'); + $this->logger->info('Registering the Spacedeck mimetype...', ['app' => Application::APP_ID]); $mimetypeMapping = [ 'whiteboard' => ['application/spacedeck'] @@ -53,6 +57,6 @@ public function run(IOutput $output) { file_put_contents($mimetypeMappingFile, json_encode($mimetypeMapping, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); - $this->logger->info('The Spacedeck mimetype was successfully registered.'); + $this->logger->info('The Spacedeck mimetype was successfully registered.', ['app' => Application::APP_ID]); } -} \ No newline at end of file +} diff --git a/lib/Migration/StopSpacedeck.php b/lib/Migration/StopSpacedeck.php index 4ff3d26..d81a951 100644 --- a/lib/Migration/StopSpacedeck.php +++ b/lib/Migration/StopSpacedeck.php @@ -21,19 +21,28 @@ namespace OCA\Spacedeck\Migration; +use OCA\Spacedeck\AppInfo\Application; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; -use OCP\ILogger; use OCA\Spacedeck\Service\SpacedeckBundleService; +use Psr\Log\LoggerInterface; class StopSpacedeck implements IRepairStep { - protected $logger; - private $customMimetypeMapping; - public function __construct(ILogger $logger, SpacedeckBundleService $service) { + /** + * @var LoggerInterface + */ + private $logger; + /** + * @var SpacedeckBundleService + */ + private $bundleService; + + public function __construct(LoggerInterface $logger, + SpacedeckBundleService $bundleService) { $this->logger = $logger; - $this->service = $service; + $this->bundleService = $bundleService; } public function getName() { @@ -43,11 +52,11 @@ public function getName() { public function run(IOutput $output) { $this->logger->info('Stopping Spacedeck...'); - $stopped = $this->service->killSpacedeck(); + $stopped = $this->bundleService->killSpacedeck(); if ($stopped) { - $this->logger->info('Spacedeck stopped!'); + $this->logger->info('Spacedeck stopped!', ['app' => Application::APP_ID]); } else { - $this->logger->warning('Failed to stop Spacedeck'); + $this->logger->warning('Failed to stop Spacedeck', ['app' => Application::APP_ID]); } } -} \ No newline at end of file +} diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index dff969d..65f727a 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -11,15 +11,17 @@ namespace OCA\Spacedeck\Service; +use OC\User\NoUserException; use OCA\Spacedeck\AppInfo\Application; +use OCP\Files\InvalidPathException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\Share\Exceptions\ShareNotFound; -use Psr\Log\LoggerInterface; use OCP\Constants; use OCP\Files\IRootFolder; use OCP\Files\FileInfo; use OCP\Files\Node; use OCP\Share\IManager as IShareManager; -use OCP\IUserManager; class FileService { @@ -27,25 +29,26 @@ class FileService { * @var IShareManager */ private $shareManager; + /** + * @var IRootFolder + */ + private $root; - public function __construct (string $appName, - IShareManager $shareManager, - IRootFolder $root, - IUserManager $userManager, - LoggerInterface $logger) { - $this->appName = $appName; - $this->logger = $logger; - $this->root = $root; - $this->userManager = $userManager; + public function __construct (string $appName, + IShareManager $shareManager, + IRootFolder $root) { $this->shareManager = $shareManager; + $this->root = $root; } /** * Get a user file from a fileId * * @param ?string $userId - * @param int $fileID + * @param int $fileId * @return ?Node the file or null if it does not exist (or is not accessible by this user) + * @throws NoUserException + * @throws NotPermittedException */ public function getFileFromId(?string $userId, int $fileId): ?Node { if (is_null($userId)) { @@ -66,8 +69,12 @@ public function getFileFromId(?string $userId, int $fileId): ?Node { * Check if user has write access on a file * * @param ?string $userId - * @param int $fileID + * @param int $fileId * @return bool true if the user can write the file + * @throws NoUserException + * @throws NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException */ public function userHasWriteAccess(string $userId, int $fileId): bool { $userFolder = $this->root->getUserFolder($userId); @@ -113,8 +120,10 @@ public function getUserPermissionsOnFile(string $userId, int $fileId): int { * Check if a share token can access a file * * @param string $shareToken - * @param int $fileId the file ID or 0 if the token target is a file (public file share page context) + * @param int $fileId * @return ?Node the file or null if this token does not exist or can't access this file + * @throws InvalidPathException + * @throws NotFoundException */ public function getFileFromShareToken(string $shareToken, int $fileId): ?Node { try { @@ -141,6 +150,8 @@ public function getFileFromShareToken(string $shareToken, int $fileId): ?Node { * @param string $shareToken * @param int $fileId * @return bool true if has write access + * @throws InvalidPathException + * @throws NotFoundException */ public function isFileWriteableWithToken(string $shareToken, int $fileId): bool { $file = $this->getFileFromShareToken($shareToken, $fileId); diff --git a/lib/Service/SessionService.php b/lib/Service/SessionService.php index 77988f3..6e457ec 100644 --- a/lib/Service/SessionService.php +++ b/lib/Service/SessionService.php @@ -11,6 +11,11 @@ namespace OCA\Spacedeck\Service; +use OC\User\NoUserException; +use OCP\DB\Exception; +use OCP\Files\InvalidPathException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\IConfig; use Psr\Log\LoggerInterface; @@ -101,6 +106,8 @@ private function saveSessionSpaceToFile(array $session) { * @param string $userId * @param int $fileId * @return array|null + * @throws NoUserException + * @throws NotPermittedException */ public function createUserSession(string $userId, int $fileId): ?array { $file = $this->fileService->getFileFromId($userId, $fileId); @@ -116,6 +123,8 @@ public function createUserSession(string $userId, int $fileId): ?array { * @param string $shareToken * @param int $fileId * @return array|null + * @throws InvalidPathException + * @throws NotFoundException */ public function createShareSession(string $shareToken, int $fileId): ?array { $file = $this->fileService->getFileFromShareToken($shareToken, $fileId); @@ -131,6 +140,7 @@ public function createShareSession(string $shareToken, int $fileId): ?array { * @param string $userId * @param string $sessionToken * @return bool + * @throws Exception */ public function deleteUserSession(string $userId, string $sessionToken): bool { $session = $this->sessionStoreService->getSession( @@ -149,6 +159,7 @@ public function deleteUserSession(string $userId, string $sessionToken): bool { * @param string $shareToken * @param string $sessionToken * @return bool + * @throws Exception */ public function deleteShareSession(string $shareToken, string $sessionToken): bool { $session = $this->sessionStoreService->getSession( diff --git a/lib/Service/SessionStoreService.php b/lib/Service/SessionStoreService.php index 4586438..3798492 100644 --- a/lib/Service/SessionStoreService.php +++ b/lib/Service/SessionStoreService.php @@ -12,9 +12,9 @@ namespace OCA\Spacedeck\Service; use DateTime; +use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use Psr\Log\LoggerInterface; use OCA\Spacedeck\AppInfo\Application; @@ -25,17 +25,21 @@ class SessionStoreService { * @var IDBConnection */ private $db; - /** - * @var LoggerInterface - */ - private $logger; - public function __construct (IDBConnection $db, - LoggerInterface $logger) { + public function __construct (IDBConnection $db) { $this->db = $db; - $this->logger = $logger; } + /** + * @param string $sessionToken + * @param string|null $ownerUid + * @param string|null $editorUid + * @param int|null $fileId + * @param string|null $shareToken + * @param int|null $tokenType + * @return array|null + * @throws Exception + */ public function getSession(string $sessionToken, ?string $ownerUid = null, ?string $editorUid = null, ?int $fileId = null, ?string $shareToken = null, ?int $tokenType = null): ?array { $qb = $this->db->getQueryBuilder(); @@ -69,6 +73,15 @@ public function getSession(string $sessionToken, ?string $ownerUid = null, ?stri return null; } + /** + * @param string|null $ownerUid + * @param string|null $editorUid + * @param int|null $fileId + * @param string|null $shareToken + * @param int|null $tokenType + * @return array + * @throws Exception + */ public function getSessions(?string $ownerUid = null, ?string $editorUid = null, ?int $fileId = null, ?string $shareToken = null, ?int $tokenType = null): array { $qb = $this->db->getQueryBuilder(); @@ -108,6 +121,10 @@ public function getSessions(?string $ownerUid = null, ?string $editorUid = null, return $sessions; } + /** + * @param array $row + * @return array + */ private function getSessionFromRow(array $row): array { return [ 'id' => (int) $row['id'], @@ -122,6 +139,14 @@ private function getSessionFromRow(array $row): array { ]; } + /** + * @param string $ownerUid + * @param int $fileId + * @param string|null $editorUid + * @param string|null $shareToken + * @return array|null + * @throws Exception + */ public function createSession(string $ownerUid, int $fileId, ?string $editorUid = null, ?string $shareToken = null): ?array { // exclusive or between editorUid and shareToken @@ -162,10 +187,19 @@ public function createSession(string $ownerUid, int $fileId, ]; } + /** + * @param string $baseString + * @return string + */ private function generateToken(string $baseString) { return md5($baseString.rand()); } + /** + * @param string $token + * @return void + * @throws Exception + */ public function deleteSession(string $token): void { $qb = $this->db->getQueryBuilder(); $qb->delete(self::SESSIONS_TABLE_NAME) @@ -176,6 +210,11 @@ public function deleteSession(string $token): void { $qb->resetQueryParts(); } + /** + * @param int $timeout + * @return array + * @throws Exception + */ public function cleanupSessions(int $timeout): array { $qb = $this->db->getQueryBuilder(); @@ -206,6 +245,11 @@ public function cleanupSessions(int $timeout): array { return $deletedSessions; } + /** + * @param string $sessionToken + * @return void + * @throws Exception + */ public function touchSession(string $sessionToken): void { $qb = $this->db->getQueryBuilder(); $nowTimestamp = (new DateTime())->getTimestamp(); diff --git a/lib/Service/SpacedeckAPIService.php b/lib/Service/SpacedeckAPIService.php index 3fcd73e..1f300bf 100644 --- a/lib/Service/SpacedeckAPIService.php +++ b/lib/Service/SpacedeckAPIService.php @@ -11,6 +11,8 @@ namespace OCA\Spacedeck\Service; +use OC\User\NoUserException; +use OCP\Files\InvalidPathException; use Psr\Log\LoggerInterface; use OCP\IConfig; use OCP\Constants; @@ -30,12 +32,38 @@ use OCA\Spacedeck\AppInfo\Application; class SpacedeckAPIService { - + /** + * @var IRootFolder + */ + private $root; + /** + * @var IUserManager + */ + private $userManager; + /** + * @var LoggerInterface + */ private $logger; + /** + * @var IConfig + */ + private $config; + /** + * @var SpacedeckBundleService + */ + private $spacedeckBundleService; /** * @var FileService */ private $fileService; + /** + * @var \OCP\Http\Client\IClient + */ + private $client; + /** + * @var bool + */ + private $useLocalSpacedeck; /** * Service to make requests to Spacedeck API @@ -48,16 +76,14 @@ public function __construct (string $appName, SpacedeckBundleService $spacedeckBundleService, FileService $fileService, IClientService $clientService) { - $this->appName = $appName; - $this->logger = $logger; - $this->config = $config; $this->root = $root; $this->userManager = $userManager; - $this->clientService = $clientService; - $this->client = $clientService->newClient(); + $this->logger = $logger; + $this->config = $config; $this->spacedeckBundleService = $spacedeckBundleService; - $this->useLocalSpacedeck = $this->config->getAppValue(Application::APP_ID, 'use_local_spacedeck', '1') === '1'; $this->fileService = $fileService; + $this->client = $clientService->newClient(); + $this->useLocalSpacedeck = $this->config->getAppValue(Application::APP_ID, 'use_local_spacedeck', '1') === '1'; } /** @@ -66,9 +92,14 @@ public function __construct (string $appName, * @param string $baseUrl * @param string $apiToken * @param ?string $userId - * @param string $space_id * @param int $file_id + * @param string $outputDirPath + * @param bool $usesIndexDotPhp * @return array success state + * @throws InvalidPathException + * @throws NoUserException + * @throws NotFoundException + * @throws NotPermittedException */ public function exportSpaceToPdf(string $baseUrl, string $apiToken, string $userId, int $file_id, string $outputDirPath, bool $usesIndexDotPhp): array { @@ -141,6 +172,10 @@ public function exportSpaceToPdf(string $baseUrl, string $apiToken, string $user * @param string $space_id * @param int $file_id * @return array success state + * @throws InvalidPathException + * @throws NoUserException + * @throws NotFoundException + * @throws NotPermittedException */ public function saveSpaceToFile(string $baseUrl, string $apiToken, ?string $userId, string $space_id, int $file_id): array { $targetFile = $this->fileService->getFileFromId($userId, $file_id); @@ -188,7 +223,10 @@ public function saveSpaceToFile(string $baseUrl, string $apiToken, ?string $user * @param string $apiToken * @param ?string $userId * @param int $file_id + * @param bool $usesIndexDotPhp * @return array error or space information + * @throws NoUserException + * @throws NotPermittedException */ public function loadSpaceFromFile(string $baseUrl, string $apiToken, ?string $userId, int $file_id, bool $usesIndexDotPhp): array { if ($this->useLocalSpacedeck) { @@ -286,11 +324,12 @@ public function loadSpaceFromFile(string $baseUrl, string $apiToken, ?string $us * @param string $spaceId * @param array $artifact * @return void + * @throws \Exception */ private function loadArtifact(string $baseUrl, string $apiToken, string $spaceId, array $artifact): void { $response = $this->apiRequest($baseUrl, $apiToken, 'spaces/' . $spaceId . '/artifacts', $artifact, 'POST'); if (isset($response['error'])) { - $this->logger->error('Error creating artifact in ' . $spaceId . ' : ' . $response['error']); + $this->logger->error('Error creating artifact in ' . $spaceId . ' : ' . $response['error'], ['app' => Application::APP_ID]); } } @@ -302,6 +341,7 @@ private function loadArtifact(string $baseUrl, string $apiToken, string $spaceId * @param ?string $userId * @param int $fileId * @return array new space request result + * @throws \Exception */ private function createSpace(string $baseUrl, string $apiToken, ?string $userId, int $fileId): array { $strFileId = strval($fileId); @@ -317,7 +357,9 @@ private function createSpace(string $baseUrl, string $apiToken, ?string $userId, * * @param string $baseUrl * @param string $apiToken + * @param bool $usesIndexDotPhp * @return array API response or request error + * @throws \Exception */ public function getSpaceList(string $baseUrl, string $apiToken, bool $usesIndexDotPhp): array { if ($this->useLocalSpacedeck) { @@ -339,6 +381,7 @@ public function getExtSpacedeckStylesheet(string $baseUrl): array { * @param string $baseUrl * @param string $apiToken * @return array with status and errors + * @throws \Exception */ public function cleanupSpacedeckStorage(string $baseUrl, string $apiToken): array { // we don't try to launch spacedeck here because urlGenerator->getBaseUrl() @@ -374,7 +417,7 @@ public function cleanupSpacedeckStorage(string $baseUrl, string $apiToken): arra // => and delete the space via the API $response = $this->apiRequest($baseUrl, $apiToken, 'spaces/' . $spaceId, [], 'DELETE'); if (isset($response['error'])) { - $this->logger->error('Error deleting space ' . $spaceId . ' : ' . $response['error']); + $this->logger->error('Error deleting space ' . $spaceId . ' : ' . $response['error'], ['app' => Application::APP_ID]); } else { $actions[] = 'Deleted space ' . $spaceId; } @@ -382,7 +425,7 @@ public function cleanupSpacedeckStorage(string $baseUrl, string $apiToken): arra // file exist: check if storage artifact data should be deleted $artifacts = $this->apiRequest($baseUrl, $apiToken, 'spaces/' . $spaceId . '/artifacts'); if (isset($artifacts['error'])) { - $this->logger->error('Error getting artifacts of space ' . $spaceId . ' : ' . $artifacts['error']); + $this->logger->error('Error getting artifacts of space ' . $spaceId . ' : ' . $artifacts['error'], ['app' => Application::APP_ID]); } else { $artifactIds = []; foreach ($artifacts as $artifact) { @@ -407,6 +450,7 @@ public function cleanupSpacedeckStorage(string $baseUrl, string $apiToken): arra * @param array $params * @param string $method * @return array json decoded response or error + * @throws \Exception */ private function apiRequest(string $baseUrl, string $apiToken, string $endPoint, array $params = [], string $method = 'GET'): array { try { @@ -474,6 +518,7 @@ private function apiRequest(string $baseUrl, string $apiToken, string $endPoint, * @param array $extraHeaders * @param ?string $stringBody * @return array depending on $jsonOutput: json decoded response or text response body or error + * @throws \Exception */ public function basicRequest(string $url, array $params = [], string $method = 'GET', bool $jsonOutput = false, array $extraHeaders = [], ?string $stringBody = null): array { diff --git a/lib/Service/SpacedeckBundleService.php b/lib/Service/SpacedeckBundleService.php index 25b3446..9f666ee 100644 --- a/lib/Service/SpacedeckBundleService.php +++ b/lib/Service/SpacedeckBundleService.php @@ -15,13 +15,8 @@ use Psr\Log\LoggerInterface; use OCP\IConfig; use OCP\Files\IRootFolder; -use OCP\Files\FileInfo; -use OCP\Files\Node; -use OCP\Lock\LockedException; use OCP\IURLGenerator; -use OCA\Spacedeck\AppInfo\Application; - function recursiveCopy($src, $dst) { $dir = opendir($src); @mkdir($dst); @@ -49,26 +44,25 @@ function recursiveDelete($str) { } return @rmdir($str); } + return true; } class SpacedeckBundleService { - private $l10n; - private $logger; + /** + * @var IURLGenerator + */ + private $urlGenerator; + /** + * @var IConfig + */ + private $config; public function __construct (string $appName, - IRootFolder $root, - LoggerInterface $logger, - IL10N $l10n, - IURLGenerator $urlGenerator, - IConfig $config) { - $this->appName = $appName; - $this->l10n = $l10n; - $this->logger = $logger; - $this->config = $config; - $this->root = $root; + IURLGenerator $urlGenerator, + IConfig $config) { $this->urlGenerator = $urlGenerator; - + $this->config = $config; $dataDirPath = $this->config->getSystemValue('datadirectory'); $instanceId = $this->config->getSystemValue('instanceid'); $this->appDataDirPath = $dataDirPath . '/appdata_' . $instanceId . '/spacedeck'; @@ -247,6 +241,7 @@ private function configUsesIndexDotPhp(): bool { /** * Add or remove index.php to spacedeck config baseUrl + * @param bool $usesIndexDotPhp */ private function setBaseUrl(bool $usesIndexDotPhp): void { $instanceBaseUrl = rtrim($this->urlGenerator->getBaseUrl(), '/'); diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index 94c828c..ab29d08 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -19,12 +19,9 @@ class Admin implements ISettings { */ private $initialStateService; - public function __construct( - string $appName, - IConfig $config, - IInitialState $initialStateService, - ?string $userId) { - $this->appName = $appName; + public function __construct(string $appName, + IConfig $config, + IInitialState $initialStateService) { $this->config = $config; $this->initialStateService = $initialStateService; } diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index a31d54c..74114e1 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -14,10 +14,8 @@ class AdminSection implements IIconSection { private $urlGenerator; public function __construct(string $appName, - IURLGenerator $urlGenerator, - IL10N $l - ) { - $this->appName = $appName; + IURLGenerator $urlGenerator, + IL10N $l) { $this->l = $l; $this->urlGenerator = $urlGenerator; } @@ -57,4 +55,4 @@ public function getIcon(): ?string { return $this->urlGenerator->imagePath('core', 'categories/integration.svg'); } -} \ No newline at end of file +}