summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/AppInfo/Application.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/AppInfo/Application.php')
-rw-r--r--apps/files_trashbin/lib/AppInfo/Application.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php
index 8e4ec255567..06a34e0df84 100644
--- a/apps/files_trashbin/lib/AppInfo/Application.php
+++ b/apps/files_trashbin/lib/AppInfo/Application.php
@@ -24,8 +24,11 @@
namespace OCA\Files_Trashbin\AppInfo;
use OCA\DAV\Connector\Sabre\Principal;
+use OCA\Files_Trashbin\Trash\ITrashManager;
+use OCA\Files_Trashbin\Trash\TrashManager;
use OCP\AppFramework\App;
use OCA\Files_Trashbin\Expiration;
+use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\Utility\ITimeFactory;
use OCA\Files_Trashbin\Capabilities;
@@ -61,5 +64,36 @@ class Application extends App {
\OC::$server->getConfig()
);
});
+
+ $container->registerService(ITrashManager::class, function(IAppContainer $c) {
+ return new TrashManager();
+ });
+
+ $this->registerTrashBackends();
+ }
+
+ public function registerTrashBackends() {
+ $server = $this->getContainer()->getServer();
+ $logger = $server->getLogger();
+ $appManager = $server->getAppManager();
+ /** @var ITrashManager $trashManager */
+ $trashManager = $this->getContainer()->getServer()->query(ITrashManager::class);
+ foreach($appManager->getInstalledApps() as $app) {
+ $appInfo = $appManager->getAppInfo($app);
+ if (isset($appInfo['trash'])) {
+ $backends = $appInfo['trash'];
+ foreach($backends as $backend) {
+ $class = $backend['@value'];
+ $for = $backend['@attributes']['for'];
+
+ try {
+ $backendObject = $server->query($class);
+ $trashManager->registerBackend($for, $backendObject);
+ } catch (\Exception $e) {
+ $logger->logException($e);
+ }
+ }
+ }
+ }
}
}