summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-03-05 16:00:47 +0100
committerMorris Jobke <hey@morrisjobke.de>2019-03-05 16:00:47 +0100
commitdd2496b2756633a961424560934a216ab1048e1b (patch)
tree32289e31339b8031061e3bb7db58e0b8ffc673c4 /apps/dav
parent789aaa489d32fb96ce5ac63c9214e783c0a6c26e (diff)
downloadnextcloud-server-dd2496b2756633a961424560934a216ab1048e1b.tar.gz
nextcloud-server-dd2496b2756633a961424560934a216ab1048e1b.zip
Use proper dependency injection for app manager
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/appinfo/v1/caldav.php1
-rw-r--r--apps/dav/appinfo/v1/carddav.php1
-rw-r--r--apps/dav/lib/Command/CreateCalendar.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/Principal.php10
-rw-r--r--apps/dav/lib/RootCollection.php3
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php9
6 files changed, 22 insertions, 5 deletions
diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php
index ecc4fbb8b60..c2634a595a3 100644
--- a/apps/dav/appinfo/v1/caldav.php
+++ b/apps/dav/appinfo/v1/caldav.php
@@ -47,6 +47,7 @@ $principalBackend = new Principal(
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
+ \OC::$server->getAppManager(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
diff --git a/apps/dav/appinfo/v1/carddav.php b/apps/dav/appinfo/v1/carddav.php
index a424d7afab9..60669df60ba 100644
--- a/apps/dav/appinfo/v1/carddav.php
+++ b/apps/dav/appinfo/v1/carddav.php
@@ -48,6 +48,7 @@ $principalBackend = new Principal(
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
+ \OC::$server->getAppManager(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
diff --git a/apps/dav/lib/Command/CreateCalendar.php b/apps/dav/lib/Command/CreateCalendar.php
index 45dd9ba941a..8e3a4abf8cf 100644
--- a/apps/dav/lib/Command/CreateCalendar.php
+++ b/apps/dav/lib/Command/CreateCalendar.php
@@ -78,7 +78,8 @@ class CreateCalendar extends Command {
$this->groupManager,
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
- \OC::$server->getConfig()
+ \OC::$server->getConfig(),
+ \OC::$server->getAppManager()
);
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->getLogger();
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php
index ca98d455b30..a441e1c8122 100644
--- a/apps/dav/lib/Connector/Sabre/Principal.php
+++ b/apps/dav/lib/Connector/Sabre/Principal.php
@@ -35,6 +35,7 @@
namespace OCA\DAV\Connector\Sabre;
use OCA\Circles\Exceptions\CircleDoesNotExistException;
+use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\IConfig;
use OCP\IGroup;
@@ -64,6 +65,9 @@ class Principal implements BackendInterface {
/** @var IConfig */
private $config;
+ /** @var IAppManager */
+ private $appManager;
+
/** @var string */
private $principalPrefix;
@@ -86,12 +90,14 @@ class Principal implements BackendInterface {
IShareManager $shareManager,
IUserSession $userSession,
IConfig $config,
+ IAppManager $appManager,
$principalPrefix = 'principals/users/') {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->shareManager = $shareManager;
$this->userSession = $userSession;
$this->config = $config;
+ $this->appManager = $appManager;
$this->principalPrefix = trim($principalPrefix, '/');
$this->hasGroups = $this->hasCircles = ($principalPrefix === 'principals/users/');
}
@@ -404,7 +410,7 @@ class Principal implements BackendInterface {
* @suppress PhanUndeclaredClassCatch
*/
protected function circleToPrincipal($circleUniqueId) {
- if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\Api\v1\Circles')) {
+ if (!$this->appManager->isEnabledForUser('circles') || !class_exists('\OCA\Circles\Api\v1\Circles')) {
return null;
}
@@ -438,7 +444,7 @@ class Principal implements BackendInterface {
* @suppress PhanUndeclaredClassMethod
*/
public function getCircleMembership($principal):array {
- if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\Api\v1\Circles')) {
+ if (!$this->appManager->isEnabledForUser('circles') || !class_exists('\OCA\Circles\Api\v1\Circles')) {
return [];
}
diff --git a/apps/dav/lib/RootCollection.php b/apps/dav/lib/RootCollection.php
index 9ad1ea5221e..38c8b2f6b47 100644
--- a/apps/dav/lib/RootCollection.php
+++ b/apps/dav/lib/RootCollection.php
@@ -58,7 +58,8 @@ class RootCollection extends SimpleCollection {
$groupManager,
$shareManager,
\OC::$server->getUserSession(),
- $config
+ $config,
+ \OC::$server->getAppManager()
);
$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $l10n);
$calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger);
diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
index b72ae0a743d..b40cd3105aa 100644
--- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
@@ -29,6 +29,7 @@
namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OC\User\User;
+use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
@@ -59,19 +60,25 @@ class PrincipalTest extends TestCase {
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
private $config;
+ /** @var IAppManager | \PHPUnit_Framework_MockObject_MockObject */
+ private $appManager;
+
public function setUp() {
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->shareManager = $this->createMock(IManager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->config = $this->createMock(IConfig::class);
+ $this->appManager = $this->createMock(IAppManager::class);
$this->connector = new \OCA\DAV\Connector\Sabre\Principal(
$this->userManager,
$this->groupManager,
$this->shareManager,
$this->userSession,
- $this->config);
+ $this->config,
+ $this->appManager
+ );
parent::setUp();
}