Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-05-12 11:45:38 +0300
committerGitHub <noreply@github.com>2022-05-12 11:45:38 +0300
commitfc1db22629e33f3550daab0c737493ad21b3a8a7 (patch)
treebf9e1a08914be9441f6fa30901980bd074d1035c /lib
parentbe49f79503a9e187cec43fabeb6f5eed9b06af6c (diff)
parenta392cd70fbdc0d73a4e2ef84340b58dcd711f535 (diff)
Merge pull request #32339 from nextcloud/appdatafactory-public
Make it possible to get the appdata folder using the public API
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Files/AppData/Factory.php21
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/public/Files/AppData/IAppDataFactory.php21
5 files changed, 34 insertions, 14 deletions
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<string, IAppData> */
+ 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 @@
+<?php
+
+namespace OCP\Files\AppData;
+
+use OCP\Files\IAppData;
+
+/**
+ * A factory allows you to get the AppData folder for an application.
+ *
+ * @since 25.0.0
+ */
+interface IAppDataFactory {
+
+ /**
+ * Get the AppData folder for the specified $appId
+ * @param string $appId
+ * @return IAppData
+ * @since 25.0.0
+ */
+ public function get(string $appId): IAppData;
+}