diff options
author | brantje <brantje@gmail.com> | 2016-12-30 17:13:00 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2016-12-30 17:47:38 +0300 |
commit | a224ce4af92356082a07e3012d51713f22b3d047 (patch) | |
tree | e3a172c51f17947773c6550a2d244db56572dca4 /lib | |
parent | 483b13dae74567b1fe3993671f1d768e756a0e3c (diff) |
Implement middleware for sharing
Check if sharing is enabled, if not return an empty array.
Signed-off-by: brantje <brantje@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 38 | ||||
-rw-r--r-- | lib/Service/SettingsService.php | 1 |
2 files changed, 25 insertions, 14 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 711365ba..01456292 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -22,12 +22,14 @@ */ namespace OCA\Passman\AppInfo; + use OC\Files\View; use OCA\Passman\Controller\CredentialController; use OCA\Passman\Controller\PageController; use OCA\Passman\Controller\ShareController; use OCA\Passman\Controller\VaultController; +use OCA\Passman\Middleware\ShareMiddleware; use OCA\Passman\Service\ActivityService; use OCA\Passman\Service\CronService; use OCA\Passman\Service\CredentialService; @@ -43,22 +45,31 @@ use OCP\IDBConnection; use OCP\AppFramework\App; use OCP\IL10N; use OCP\Util; + class Application extends App { - public function __construct () { + public function __construct() { parent::__construct('passman'); $container = $this->getContainer(); // Allow automatic DI for the View, until we migrated to Nodes API - $container->registerService(View::class, function() { + $container->registerService(View::class, function () { return new View(''); }, false); - $container->registerService('isCLI', function() { + $container->registerService('isCLI', function () { return \OC::$CLI; }); /** + * Middleware + */ + $container->registerService('ShareMiddleware', function ($c) { + return new ShareMiddleware($c->query('SettingsService')); + }); + $container->registerMiddleware('ShareMiddleware'); + + /** * Controllers */ - $container->registerService('ShareController', function($c) { + $container->registerService('ShareController', function ($c) { $container = $this->getContainer(); $server = $container->getServer(); return new ShareController( @@ -67,18 +78,17 @@ class Application extends App { $server->getUserSession()->getUser(), $server->getGroupManager(), $server->getUserManager(), - $c->query('ActivityService'), - $c->query('VaultService'), - $c->query('ShareService'), - $c->query('CredentialService'), - $c->query('NotificationService'), - $c->query('FileService'), - $c->query('SettingsService') + $c->query('ActivityService'), + $c->query('VaultService'), + $c->query('ShareService'), + $c->query('CredentialService'), + $c->query('NotificationService'), + $c->query('FileService'), + $c->query('SettingsService') ); }); - /** Cron **/ $container->registerService('CronService', function ($c) { return new CronService( @@ -95,7 +105,7 @@ class Application extends App { return new Db(); }); - $container->registerService('Logger', function($c) { + $container->registerService('Logger', function ($c) { return $c->query('ServerContainer')->getLogger(); }); @@ -109,7 +119,7 @@ class Application extends App { $container->registerAlias('ActivityService', ActivityService::class); $container->registerAlias('VaultService', VaultService::class); $container->registerAlias('FileService', FileService::class); - $container->registerAlias('ShareService', ShareService::class); + $container->registerAlias('ShareService', ShareService::class); $container->registerAlias('Utils', Utils::class); $container->registerAlias('IDBConnection', IDBConnection::class); $container->registerAlias('IConfig', IConfig::class); diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index c61af779..8c9d9d67 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -61,6 +61,7 @@ class SettingsService { 'check_version' => intval($this->config->getAppValue('passman', 'check_version', 1)), 'https_check' => intval($this->config->getAppValue('passman', 'https_check', 1)), 'disable_contextmenu' => intval($this->config->getAppValue('passman', 'disable_contextmenu', 1)), + 'settings_loaded' => 1 ); return $this->settings; } |