From: Carl Schwan Date: Wed, 11 May 2022 14:45:32 +0000 (+0200) Subject: Make it possible to get the appdata folder using the public API X-Git-Tag: v25.0.0beta1~439^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F32339%2Fhead;p=nextcloud-server.git Make it possible to get the appdata folder using the public API Signed-off-by: Carl Schwan --- diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 233c374edbf..d1fb89098c5 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -236,6 +236,7 @@ return array( 'OCP\\Federation\\ICloudIdManager' => $baseDir . '/lib/public/Federation/ICloudIdManager.php', 'OCP\\Files' => $baseDir . '/lib/public/Files.php', 'OCP\\Files\\AlreadyExistsException' => $baseDir . '/lib/public/Files/AlreadyExistsException.php', + 'OCP\\Files\\AppData\\IAppDataFactory' => $baseDir . '/lib/public/Files/AppData/IAppDataFactory.php', 'OCP\\Files\\Cache\\AbstractCacheEvent' => $baseDir . '/lib/public/Files/Cache/AbstractCacheEvent.php', 'OCP\\Files\\Cache\\CacheEntryInsertedEvent' => $baseDir . '/lib/public/Files/Cache/CacheEntryInsertedEvent.php', 'OCP\\Files\\Cache\\CacheEntryRemovedEvent' => $baseDir . '/lib/public/Files/Cache/CacheEntryRemovedEvent.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 0b59d14657d..0aae979596c 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -265,6 +265,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Federation\\ICloudIdManager' => __DIR__ . '/../../..' . '/lib/public/Federation/ICloudIdManager.php', 'OCP\\Files' => __DIR__ . '/../../..' . '/lib/public/Files.php', 'OCP\\Files\\AlreadyExistsException' => __DIR__ . '/../../..' . '/lib/public/Files/AlreadyExistsException.php', + 'OCP\\Files\\AppData\\IAppDataFactory' => __DIR__ . '/../../..' . '/lib/public/Files/AppData/IAppDataFactory.php', 'OCP\\Files\\Cache\\AbstractCacheEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/AbstractCacheEvent.php', 'OCP\\Files\\Cache\\CacheEntryInsertedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheEntryInsertedEvent.php', 'OCP\\Files\\Cache\\CacheEntryRemovedEvent' => __DIR__ . '/../../..' . '/lib/public/Files/Cache/CacheEntryRemovedEvent.php', diff --git a/lib/private/Files/AppData/Factory.php b/lib/private/Files/AppData/Factory.php index 6d7483158f6..03f8fdedcbd 100644 --- a/lib/private/Files/AppData/Factory.php +++ b/lib/private/Files/AppData/Factory.php @@ -27,17 +27,16 @@ declare(strict_types=1); namespace OC\Files\AppData; use OC\SystemConfig; +use OCP\Files\AppData\IAppDataFactory; +use OCP\Files\IAppData; use OCP\Files\IRootFolder; -class Factory { +class Factory implements IAppDataFactory { + private IRootFolder $rootFolder; + private SystemConfig $config; - /** @var IRootFolder */ - private $rootFolder; - - /** @var SystemConfig */ - private $config; - - private $folders = []; + /** @var array */ + private array $folders = []; public function __construct(IRootFolder $rootFolder, SystemConfig $systemConfig) { @@ -45,11 +44,7 @@ class Factory { $this->config = $systemConfig; } - /** - * @param string $appId - * @return AppData - */ - public function get(string $appId): AppData { + public function get(string $appId): IAppData { if (!isset($this->folders[$appId])) { $this->folders[$appId] = new AppData($this->rootFolder, $this->config, $appId); } diff --git a/lib/private/Server.php b/lib/private/Server.php index 5308de21f51..1c330c0c74f 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1439,6 +1439,8 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(IMetadataManager::class, MetadataManager::class); + $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class); + $this->connectDispatcher(); } @@ -2300,7 +2302,7 @@ class Server extends ServerContainer implements IServerContainer { /** * @return \OCP\Files\IAppData - * @deprecated 20.0.0 + * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead */ public function getAppDataDir($app) { /** @var \OC\Files\AppData\Factory $factory */ diff --git a/lib/public/Files/AppData/IAppDataFactory.php b/lib/public/Files/AppData/IAppDataFactory.php new file mode 100644 index 00000000000..b689da36b83 --- /dev/null +++ b/lib/public/Files/AppData/IAppDataFactory.php @@ -0,0 +1,21 @@ +