Use proper dependency injection for app manager
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
789aaa489d
commit
dd2496b275
|
@ -47,6 +47,7 @@ $principalBackend = new Principal(
|
|||
\OC::$server->getShareManager(),
|
||||
\OC::$server->getUserSession(),
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getAppManager(),
|
||||
'principals/'
|
||||
);
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
|
|
|
@ -48,6 +48,7 @@ $principalBackend = new Principal(
|
|||
\OC::$server->getShareManager(),
|
||||
\OC::$server->getUserSession(),
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getAppManager(),
|
||||
'principals/'
|
||||
);
|
||||
$db = \OC::$server->getDatabaseConnection();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 [];
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ class Application extends App {
|
|||
\OC::$server->getGroupManager(),
|
||||
\OC::$server->getShareManager(),
|
||||
\OC::$server->getUserSession(),
|
||||
\OC::$server->getConfig()
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getAppManager()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ class Application extends App {
|
|||
$server->getGroupManager(),
|
||||
$server->getShareManager(),
|
||||
$server->getUserSession(),
|
||||
$server->getConfig()
|
||||
$server->getConfig(),
|
||||
$server->getAppManager()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue