2016-08-24 06:03:22 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-05-08 08:42:48 -04:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2016-08-24 06:03:22 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-08-24 06:03:22 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\Files\AppData;
|
|
|
|
|
|
|
|
|
|
use OC\SystemConfig;
|
2022-05-11 10:45:32 -04:00
|
|
|
use OCP\Files\AppData\IAppDataFactory;
|
|
|
|
|
use OCP\Files\IAppData;
|
2016-08-24 06:03:22 -04:00
|
|
|
use OCP\Files\IRootFolder;
|
|
|
|
|
|
2022-05-11 10:45:32 -04:00
|
|
|
class Factory implements IAppDataFactory {
|
|
|
|
|
private IRootFolder $rootFolder;
|
|
|
|
|
private SystemConfig $config;
|
2016-08-24 06:03:22 -04:00
|
|
|
|
2022-05-11 10:45:32 -04:00
|
|
|
/** @var array<string, IAppData> */
|
|
|
|
|
private array $folders = [];
|
2018-12-06 07:58:57 -05:00
|
|
|
|
2016-08-24 06:03:22 -04:00
|
|
|
public function __construct(IRootFolder $rootFolder,
|
|
|
|
|
SystemConfig $systemConfig) {
|
|
|
|
|
$this->rootFolder = $rootFolder;
|
|
|
|
|
$this->config = $systemConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 10:45:32 -04:00
|
|
|
public function get(string $appId): IAppData {
|
2018-12-06 07:58:57 -05:00
|
|
|
if (!isset($this->folders[$appId])) {
|
|
|
|
|
$this->folders[$appId] = new AppData($this->rootFolder, $this->config, $appId);
|
|
|
|
|
}
|
|
|
|
|
return $this->folders[$appId];
|
2016-08-24 06:03:22 -04:00
|
|
|
}
|
|
|
|
|
}
|