aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/AppInfo
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-22 22:11:01 +0200
committerMorris Jobke <hey@morrisjobke.de>2020-07-23 22:03:14 +0200
commite84504c4d6a079d55d2f78ad21b1ad20d53035bb (patch)
treeb1ac43a8573169257ee0c8d56d1dfd406cf68f59 /apps/files_trashbin/lib/AppInfo
parentc842678f0a1fb65981a03302895192ddc58479c9 (diff)
downloadnextcloud-server-e84504c4d6a079d55d2f78ad21b1ad20d53035bb.tar.gz
nextcloud-server-e84504c4d6a079d55d2f78ad21b1ad20d53035bb.zip
Use IBootstrap for the files_trashbin app
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_trashbin/lib/AppInfo')
-rw-r--r--apps/files_trashbin/lib/AppInfo/Application.php74
1 files changed, 38 insertions, 36 deletions
diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php
index d9f52d21a61..ed78709a5d6 100644
--- a/apps/files_trashbin/lib/AppInfo/Application.php
+++ b/apps/files_trashbin/lib/AppInfo/Application.php
@@ -27,57 +27,59 @@
namespace OCA\Files_Trashbin\AppInfo;
-use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
use OCA\Files_Trashbin\Capabilities;
use OCA\Files_Trashbin\Expiration;
use OCA\Files_Trashbin\Trash\ITrashManager;
use OCA\Files_Trashbin\Trash\TrashManager;
+use OCP\App\IAppManager;
use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\ILogger;
+use OCP\IServerContainer;
-class Application extends App {
+class Application extends App implements IBootstrap {
public function __construct(array $urlParams = []) {
parent::__construct('files_trashbin', $urlParams);
+ }
- $container = $this->getContainer();
- /*
- * Register capabilities
- */
- $container->registerCapability(Capabilities::class);
+ public function register(IRegistrationContext $context): void {
+ $context->registerCapability(Capabilities::class);
- /*
- * Register expiration
- */
- $container->registerAlias('Expiration', Expiration::class);
+ $context->registerServiceAlias('Expiration', Expiration::class);
+ $context->registerServiceAlias(ITrashManager::class, TrashManager::class);
+ /** Register $principalBackend for the DAV collection */
+ $context->registerServiceAlias('principalBackend', Principal::class);
+ }
- /*
- * Register $principalBackend for the DAV collection
- */
- $container->registerService('principalBackend', function () {
- return new Principal(
- \OC::$server->getUserManager(),
- \OC::$server->getGroupManager(),
- \OC::$server->getShareManager(),
- \OC::$server->getUserSession(),
- \OC::$server->getAppManager(),
- \OC::$server->query(ProxyMapper::class),
- \OC::$server->getConfig()
- );
- });
+ public function boot(IBootContext $context): void {
+ $context->injectFn([$this, 'registerTrashBackends']);
- $container->registerService(ITrashManager::class, function () {
- return new TrashManager();
- });
+ // create storage wrapper on setup
+ \OCP\Util::connectHook('OC_Filesystem', 'preSetup', 'OCA\Files_Trashbin\Storage', 'setupStorage');
+ //Listen to delete user signal
+ \OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\Files_Trashbin\Hooks', 'deleteUser_hook');
+ //Listen to post write hook
+ \OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Files_Trashbin\Hooks', 'post_write_hook');
+ // pre and post-rename, disable trash logic for the copy+unlink case
+ \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook');
- $this->registerTrashBackends();
+ \OCA\Files\App::getNavigationManager()->add(function () {
+ $l = \OC::$server->getL10N('files_trashbin');
+ return [
+ 'id' => 'trashbin',
+ 'appname' => 'files_trashbin',
+ 'script' => 'list.php',
+ 'order' => 50,
+ 'name' => $l->t('Deleted files'),
+ 'classes' => 'pinned',
+ ];
+ });
}
- public function registerTrashBackends() {
- $server = $this->getContainer()->getServer();
- $logger = $server->getLogger();
- $appManager = $server->getAppManager();
- /** @var ITrashManager $trashManager */
- $trashManager = $this->getContainer()->getServer()->query(ITrashManager::class);
+ public function registerTrashBackends(IServerContainer $serverContainer, ILogger $logger, IAppManager $appManager, ITrashManager $trashManager) {
foreach ($appManager->getInstalledApps() as $app) {
$appInfo = $appManager->getAppInfo($app);
if (isset($appInfo['trash'])) {
@@ -87,7 +89,7 @@ class Application extends App {
$for = $backend['@attributes']['for'];
try {
- $backendObject = $server->query($class);
+ $backendObject = $serverContainer->query($class);
$trashManager->registerBackend($for, $backendObject);
} catch (\Exception $e) {
$logger->logException($e);