Use dependency injection for app manager
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
9bb13fb05f
commit
389c2095a6
|
@ -25,6 +25,7 @@
|
||||||
namespace OCA\DAV\Connector\Sabre;
|
namespace OCA\DAV\Connector\Sabre;
|
||||||
|
|
||||||
use OC\Files\View;
|
use OC\Files\View;
|
||||||
|
use OCP\App\IAppManager;
|
||||||
use Sabre\DAV\Exception\PreconditionFailed;
|
use Sabre\DAV\Exception\PreconditionFailed;
|
||||||
use Sabre\DAV\Exception\BadRequest;
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
use Sabre\DAV\ServerPlugin;
|
use Sabre\DAV\ServerPlugin;
|
||||||
|
@ -97,6 +98,11 @@ class FilesReportPlugin extends ServerPlugin {
|
||||||
*/
|
*/
|
||||||
private $userFolder;
|
private $userFolder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IAppManager
|
||||||
|
*/
|
||||||
|
private $appManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Tree $tree
|
* @param Tree $tree
|
||||||
* @param View $view
|
* @param View $view
|
||||||
|
@ -106,6 +112,7 @@ class FilesReportPlugin extends ServerPlugin {
|
||||||
* @param IUserSession $userSession
|
* @param IUserSession $userSession
|
||||||
* @param IGroupManager $groupManager
|
* @param IGroupManager $groupManager
|
||||||
* @param Folder $userFolder
|
* @param Folder $userFolder
|
||||||
|
* @param IAppManager $appManager
|
||||||
*/
|
*/
|
||||||
public function __construct(Tree $tree,
|
public function __construct(Tree $tree,
|
||||||
View $view,
|
View $view,
|
||||||
|
@ -114,7 +121,8 @@ class FilesReportPlugin extends ServerPlugin {
|
||||||
ITagManager $fileTagger,
|
ITagManager $fileTagger,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
Folder $userFolder
|
Folder $userFolder,
|
||||||
|
IAppManager $appManager
|
||||||
) {
|
) {
|
||||||
$this->tree = $tree;
|
$this->tree = $tree;
|
||||||
$this->fileView = $view;
|
$this->fileView = $view;
|
||||||
|
@ -124,6 +132,7 @@ class FilesReportPlugin extends ServerPlugin {
|
||||||
$this->userSession = $userSession;
|
$this->userSession = $userSession;
|
||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->userFolder = $userFolder;
|
$this->userFolder = $userFolder;
|
||||||
|
$this->appManager = $appManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +358,7 @@ class FilesReportPlugin extends ServerPlugin {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getCirclesFileIds(array $circlesIds) {
|
private function getCirclesFileIds(array $circlesIds) {
|
||||||
if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
if (!$this->appManager->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
return \OCA\Circles\Api\v1\Circles::getFilesForCircles($circlesIds);
|
return \OCA\Circles\Api\v1\Circles::getFilesForCircles($circlesIds);
|
||||||
|
|
|
@ -180,7 +180,8 @@ class ServerFactory {
|
||||||
\OC::$server->getTagManager(),
|
\OC::$server->getTagManager(),
|
||||||
$this->userSession,
|
$this->userSession,
|
||||||
\OC::$server->getGroupManager(),
|
\OC::$server->getGroupManager(),
|
||||||
$userFolder
|
$userFolder,
|
||||||
|
\OC::$server->getAppManager()
|
||||||
));
|
));
|
||||||
// custom properties plugin must be the last one
|
// custom properties plugin must be the last one
|
||||||
$server->addPlugin(
|
$server->addPlugin(
|
||||||
|
|
|
@ -271,7 +271,8 @@ class Server {
|
||||||
\OC::$server->getTagManager(),
|
\OC::$server->getTagManager(),
|
||||||
$userSession,
|
$userSession,
|
||||||
\OC::$server->getGroupManager(),
|
\OC::$server->getGroupManager(),
|
||||||
$userFolder
|
$userFolder,
|
||||||
|
\OC::$server->getAppManager()
|
||||||
));
|
));
|
||||||
$lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
|
$lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend(
|
||||||
$this->server->tree,
|
$this->server->tree,
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
|
||||||
|
|
||||||
use OCA\DAV\Connector\Sabre\Directory;
|
use OCA\DAV\Connector\Sabre\Directory;
|
||||||
use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation;
|
use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation;
|
||||||
|
use OCP\App\IAppManager;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IPreview;
|
use OCP\IPreview;
|
||||||
|
@ -81,6 +82,9 @@ class FilesReportPluginTest extends \Test\TestCase {
|
||||||
/** @var IPreview|\PHPUnit_Framework_MockObject_MockObject * */
|
/** @var IPreview|\PHPUnit_Framework_MockObject_MockObject * */
|
||||||
private $previewManager;
|
private $previewManager;
|
||||||
|
|
||||||
|
/** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject * */
|
||||||
|
private $appManager;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->tree = $this->getMockBuilder(Tree::class)
|
$this->tree = $this->getMockBuilder(Tree::class)
|
||||||
|
@ -112,6 +116,10 @@ class FilesReportPluginTest extends \Test\TestCase {
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
$this->appManager = $this->getMockBuilder(IAppManager::class)
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
$this->tagManager = $this->createMock(ISystemTagManager::class);
|
$this->tagManager = $this->createMock(ISystemTagManager::class);
|
||||||
$this->tagMapper = $this->createMock(ISystemTagObjectMapper::class);
|
$this->tagMapper = $this->createMock(ISystemTagObjectMapper::class);
|
||||||
$this->userSession = $this->createMock(IUserSession::class);
|
$this->userSession = $this->createMock(IUserSession::class);
|
||||||
|
@ -140,7 +148,8 @@ class FilesReportPluginTest extends \Test\TestCase {
|
||||||
$privateTagManager,
|
$privateTagManager,
|
||||||
$this->userSession,
|
$this->userSession,
|
||||||
$this->groupManager,
|
$this->groupManager,
|
||||||
$this->userFolder
|
$this->userFolder,
|
||||||
|
$this->appManager
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue