@@ -31,30 +31,30 @@ |
||
31 | 31 | |
32 | 32 | class ContactsMenuController extends Controller { |
33 | 33 | |
34 | - /** @var Manager */ |
|
35 | - private $manager; |
|
36 | - |
|
37 | - /** @var string */ |
|
38 | - private $userId; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param IRequest $request |
|
42 | - * @param string $UserId |
|
43 | - */ |
|
44 | - public function __construct(IRequest $request, $UserId, Manager $manager) { |
|
45 | - parent::__construct('core', $request); |
|
46 | - $this->userId = $UserId; |
|
47 | - $this->manager = $manager; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @NoAdminRequired |
|
52 | - * |
|
53 | - * @param string|null filter |
|
54 | - * @return JSONResponse |
|
55 | - */ |
|
56 | - public function index($filter = null) { |
|
57 | - return $this->manager->getEntries($this->userId, $filter); |
|
58 | - } |
|
34 | + /** @var Manager */ |
|
35 | + private $manager; |
|
36 | + |
|
37 | + /** @var string */ |
|
38 | + private $userId; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param IRequest $request |
|
42 | + * @param string $UserId |
|
43 | + */ |
|
44 | + public function __construct(IRequest $request, $UserId, Manager $manager) { |
|
45 | + parent::__construct('core', $request); |
|
46 | + $this->userId = $UserId; |
|
47 | + $this->manager = $manager; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @NoAdminRequired |
|
52 | + * |
|
53 | + * @param string|null filter |
|
54 | + * @return JSONResponse |
|
55 | + */ |
|
56 | + public function index($filter = null) { |
|
57 | + return $this->manager->getEntries($this->userId, $filter); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | |
36 | 36 | $application = new Application(); |
37 | 37 | $application->registerRoutes($this, [ |
38 | - 'routes' => [ |
|
39 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
60 | - ], |
|
61 | - 'ocs' => [ |
|
62 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | - ], |
|
38 | + 'routes' => [ |
|
39 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'GET'], |
|
60 | + ], |
|
61 | + 'ocs' => [ |
|
62 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | + ], |
|
67 | 67 | ]); |
68 | 68 | |
69 | 69 | // Post installation check |
@@ -72,36 +72,36 @@ discard block |
||
72 | 72 | // Core ajax actions |
73 | 73 | // Search |
74 | 74 | $this->create('search_ajax_search', '/core/search') |
75 | - ->actionInclude('core/search/ajax/search.php'); |
|
75 | + ->actionInclude('core/search/ajax/search.php'); |
|
76 | 76 | // Routing |
77 | 77 | $this->create('core_ajax_update', '/core/ajax/update.php') |
78 | - ->actionInclude('core/ajax/update.php'); |
|
78 | + ->actionInclude('core/ajax/update.php'); |
|
79 | 79 | |
80 | 80 | // File routes |
81 | 81 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
82 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | - $app->dispatch('ViewController', 'index'); |
|
82 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | + $app->dispatch('ViewController', 'index'); |
|
84 | 84 | }); |
85 | 85 | |
86 | 86 | // Sharing routes |
87 | 87 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
88 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | - $app->dispatch('ShareController', 'showShare'); |
|
88 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | + $app->dispatch('ShareController', 'showShare'); |
|
90 | 90 | }); |
91 | 91 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
92 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | - $app->dispatch('ShareController', 'authenticate'); |
|
92 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | + $app->dispatch('ShareController', 'authenticate'); |
|
94 | 94 | }); |
95 | 95 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
96 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
96 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
98 | 98 | }); |
99 | 99 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
100 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | - $app->dispatch('ShareController', 'downloadShare'); |
|
100 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | + $app->dispatch('ShareController', 'downloadShare'); |
|
102 | 102 | }); |
103 | 103 | |
104 | 104 | // used for heartbeat |
105 | 105 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
106 | - // do nothing |
|
106 | + // do nothing |
|
107 | 107 | }); |
@@ -33,52 +33,52 @@ |
||
33 | 33 | |
34 | 34 | class ActionProviderStore { |
35 | 35 | |
36 | - /** @var IServerContainer */ |
|
37 | - private $serverContainer; |
|
36 | + /** @var IServerContainer */ |
|
37 | + private $serverContainer; |
|
38 | 38 | |
39 | - /** @var ILogger */ |
|
40 | - private $logger; |
|
39 | + /** @var ILogger */ |
|
40 | + private $logger; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IServerContainer $serverContainer |
|
44 | - */ |
|
45 | - public function __construct(IServerContainer $serverContainer, ILogger $logger) { |
|
46 | - $this->serverContainer = $serverContainer; |
|
47 | - $this->logger = $logger; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @param IServerContainer $serverContainer |
|
44 | + */ |
|
45 | + public function __construct(IServerContainer $serverContainer, ILogger $logger) { |
|
46 | + $this->serverContainer = $serverContainer; |
|
47 | + $this->logger = $logger; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return IProvider[] |
|
52 | - * @throws Exception |
|
53 | - */ |
|
54 | - public function getProviders() { |
|
55 | - // TODO: include apps |
|
56 | - $providerClasses = $this->getServerProviderClasses(); |
|
57 | - $providers = []; |
|
50 | + /** |
|
51 | + * @return IProvider[] |
|
52 | + * @throws Exception |
|
53 | + */ |
|
54 | + public function getProviders() { |
|
55 | + // TODO: include apps |
|
56 | + $providerClasses = $this->getServerProviderClasses(); |
|
57 | + $providers = []; |
|
58 | 58 | |
59 | - foreach ($providerClasses as $class) { |
|
60 | - try { |
|
61 | - $providers[] = $this->serverContainer->query($class); |
|
62 | - } catch (QueryException $ex) { |
|
63 | - $this->logger->logException($ex, [ |
|
64 | - 'message' => "Could not load contacts menu action provider $class", |
|
65 | - 'app' => 'core', |
|
66 | - ]); |
|
67 | - throw new \Exception("Could not load contacts menu action provider"); |
|
68 | - } |
|
69 | - } |
|
59 | + foreach ($providerClasses as $class) { |
|
60 | + try { |
|
61 | + $providers[] = $this->serverContainer->query($class); |
|
62 | + } catch (QueryException $ex) { |
|
63 | + $this->logger->logException($ex, [ |
|
64 | + 'message' => "Could not load contacts menu action provider $class", |
|
65 | + 'app' => 'core', |
|
66 | + ]); |
|
67 | + throw new \Exception("Could not load contacts menu action provider"); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - return $providers; |
|
72 | - } |
|
71 | + return $providers; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string[] |
|
76 | - */ |
|
77 | - private function getServerProviderClasses() { |
|
78 | - return [ |
|
79 | - EMailProvider::class, |
|
80 | - DetailsProvider::class, |
|
81 | - ]; |
|
82 | - } |
|
74 | + /** |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | + private function getServerProviderClasses() { |
|
78 | + return [ |
|
79 | + EMailProvider::class, |
|
80 | + DetailsProvider::class, |
|
81 | + ]; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -29,56 +29,56 @@ |
||
29 | 29 | |
30 | 30 | class ContactsStore { |
31 | 31 | |
32 | - /** @var IManager */ |
|
33 | - private $contactsManager; |
|
32 | + /** @var IManager */ |
|
33 | + private $contactsManager; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param IManager $contactsManager |
|
37 | - */ |
|
38 | - public function __construct(IManager $contactsManager) { |
|
39 | - $this->contactsManager = $contactsManager; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @param IManager $contactsManager |
|
37 | + */ |
|
38 | + public function __construct(IManager $contactsManager) { |
|
39 | + $this->contactsManager = $contactsManager; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string|null $filter |
|
44 | - * @return IEntry[] |
|
45 | - */ |
|
46 | - public function getContacts($filter) { |
|
47 | - $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | - 'FN', |
|
49 | - ]); |
|
42 | + /** |
|
43 | + * @param string|null $filter |
|
44 | + * @return IEntry[] |
|
45 | + */ |
|
46 | + public function getContacts($filter) { |
|
47 | + $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
48 | + 'FN', |
|
49 | + ]); |
|
50 | 50 | |
51 | - return array_map(function(array $contact) { |
|
52 | - return $this->contactArrayToEntry($contact); |
|
53 | - }, $allContacts); |
|
54 | - } |
|
51 | + return array_map(function(array $contact) { |
|
52 | + return $this->contactArrayToEntry($contact); |
|
53 | + }, $allContacts); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param array $contact |
|
58 | - * @return Entry |
|
59 | - */ |
|
60 | - private function contactArrayToEntry(array $contact) { |
|
61 | - $entry = new Entry(); |
|
56 | + /** |
|
57 | + * @param array $contact |
|
58 | + * @return Entry |
|
59 | + */ |
|
60 | + private function contactArrayToEntry(array $contact) { |
|
61 | + $entry = new Entry(); |
|
62 | 62 | |
63 | - if (isset($contact['id'])) { |
|
64 | - $entry->setId($contact['id']); |
|
65 | - } |
|
63 | + if (isset($contact['id'])) { |
|
64 | + $entry->setId($contact['id']); |
|
65 | + } |
|
66 | 66 | |
67 | - if (isset($contact['FN'])) { |
|
68 | - $entry->setFullName($contact['FN']); |
|
69 | - } |
|
67 | + if (isset($contact['FN'])) { |
|
68 | + $entry->setFullName($contact['FN']); |
|
69 | + } |
|
70 | 70 | |
71 | - if (isset($contact['EMAIL'])) { |
|
72 | - foreach ($contact['EMAIL'] as $email) { |
|
73 | - $entry->addEMailAddress($email); |
|
74 | - } |
|
75 | - } |
|
71 | + if (isset($contact['EMAIL'])) { |
|
72 | + foreach ($contact['EMAIL'] as $email) { |
|
73 | + $entry->addEMailAddress($email); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - // Attach all other properties to the entry too becuase some |
|
78 | - // providers might make use of it. |
|
79 | - $entry->setProperties($contact); |
|
77 | + // Attach all other properties to the entry too becuase some |
|
78 | + // providers might make use of it. |
|
79 | + $entry->setProperties($contact); |
|
80 | 80 | |
81 | - return $entry; |
|
82 | - } |
|
81 | + return $entry; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -30,28 +30,28 @@ |
||
30 | 30 | |
31 | 31 | class ActionFactory implements IActionFactory { |
32 | 32 | |
33 | - /** |
|
34 | - * @param string $icon |
|
35 | - * @param string $name |
|
36 | - * @param string $href |
|
37 | - * @return ILinkAction |
|
38 | - */ |
|
39 | - public function newLinkAction($icon, $name, $href) { |
|
40 | - $action = new LinkAction(); |
|
41 | - $action->setName($name); |
|
42 | - $action->setIcon($icon); |
|
43 | - $action->setHref($href); |
|
44 | - return $action; |
|
45 | - } |
|
33 | + /** |
|
34 | + * @param string $icon |
|
35 | + * @param string $name |
|
36 | + * @param string $href |
|
37 | + * @return ILinkAction |
|
38 | + */ |
|
39 | + public function newLinkAction($icon, $name, $href) { |
|
40 | + $action = new LinkAction(); |
|
41 | + $action->setName($name); |
|
42 | + $action->setIcon($icon); |
|
43 | + $action->setHref($href); |
|
44 | + return $action; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $icon |
|
49 | - * @param string $name |
|
50 | - * @param string $email |
|
51 | - * @return ILinkAction |
|
52 | - */ |
|
53 | - public function newEMailAction($icon, $name, $email) { |
|
54 | - return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
55 | - } |
|
47 | + /** |
|
48 | + * @param string $icon |
|
49 | + * @param string $name |
|
50 | + * @param string $email |
|
51 | + * @return ILinkAction |
|
52 | + */ |
|
53 | + public function newEMailAction($icon, $name, $email) { |
|
54 | + return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | * @return ILinkAction |
52 | 52 | */ |
53 | 53 | public function newEMailAction($icon, $name, $email) { |
54 | - return $this->newLinkAction($icon, $name, 'mailto:' . urlencode($email)); |
|
54 | + return $this->newLinkAction($icon, $name, 'mailto:'.urlencode($email)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | } |
@@ -28,76 +28,76 @@ |
||
28 | 28 | |
29 | 29 | class LinkAction implements ILinkAction { |
30 | 30 | |
31 | - /** @var string */ |
|
32 | - private $icon; |
|
33 | - |
|
34 | - /** @var string */ |
|
35 | - private $name; |
|
36 | - |
|
37 | - /** @var string */ |
|
38 | - private $href; |
|
39 | - |
|
40 | - /** @var int */ |
|
41 | - private $priority = 10; |
|
42 | - |
|
43 | - /** |
|
44 | - * @param string $icon absolute URI to an icon |
|
45 | - */ |
|
46 | - public function setIcon($icon) { |
|
47 | - $this->icon = $icon; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $name |
|
52 | - */ |
|
53 | - public function setName($name) { |
|
54 | - $this->name = $name; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getName() { |
|
61 | - return $this->name; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param int $priority |
|
66 | - */ |
|
67 | - public function setPriority($priority) { |
|
68 | - $this->priority = $priority; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - public function getPriority() { |
|
75 | - return $this->priority; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $href |
|
80 | - */ |
|
81 | - public function setHref($href) { |
|
82 | - $this->href = $href; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function getHref() { |
|
89 | - return $this->href; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function jsonSerialize() { |
|
96 | - return [ |
|
97 | - 'title' => $this->name, |
|
98 | - 'icon' => $this->icon, |
|
99 | - 'hyperlink' => $this->href, |
|
100 | - ]; |
|
101 | - } |
|
31 | + /** @var string */ |
|
32 | + private $icon; |
|
33 | + |
|
34 | + /** @var string */ |
|
35 | + private $name; |
|
36 | + |
|
37 | + /** @var string */ |
|
38 | + private $href; |
|
39 | + |
|
40 | + /** @var int */ |
|
41 | + private $priority = 10; |
|
42 | + |
|
43 | + /** |
|
44 | + * @param string $icon absolute URI to an icon |
|
45 | + */ |
|
46 | + public function setIcon($icon) { |
|
47 | + $this->icon = $icon; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $name |
|
52 | + */ |
|
53 | + public function setName($name) { |
|
54 | + $this->name = $name; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getName() { |
|
61 | + return $this->name; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param int $priority |
|
66 | + */ |
|
67 | + public function setPriority($priority) { |
|
68 | + $this->priority = $priority; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @return int |
|
73 | + */ |
|
74 | + public function getPriority() { |
|
75 | + return $this->priority; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $href |
|
80 | + */ |
|
81 | + public function setHref($href) { |
|
82 | + $this->href = $href; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function getHref() { |
|
89 | + return $this->href; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function jsonSerialize() { |
|
96 | + return [ |
|
97 | + 'title' => $this->name, |
|
98 | + 'icon' => $this->icon, |
|
99 | + 'hyperlink' => $this->href, |
|
100 | + ]; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | } |
@@ -30,27 +30,27 @@ |
||
30 | 30 | |
31 | 31 | class EMailProvider implements IProvider { |
32 | 32 | |
33 | - /** @var IActionFactory */ |
|
34 | - private $actionFactory; |
|
35 | - |
|
36 | - /** |
|
37 | - * @param IActionFactory $actionFactory |
|
38 | - */ |
|
39 | - public function __construct(IActionFactory $actionFactory) { |
|
40 | - $this->actionFactory = $actionFactory; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @param IEntry $entry |
|
45 | - */ |
|
46 | - public function process(IEntry $entry) { |
|
47 | - foreach ($entry->getEMailAddresses() as $address) { |
|
48 | - // TODO: absolute path |
|
49 | - // TODO: meaningful URL |
|
50 | - // TODO: l10n |
|
51 | - $action = $this->actionFactory->newEMailAction('icon-mail', 'Mail', $address); |
|
52 | - $entry->addAction($action); |
|
53 | - } |
|
54 | - } |
|
33 | + /** @var IActionFactory */ |
|
34 | + private $actionFactory; |
|
35 | + |
|
36 | + /** |
|
37 | + * @param IActionFactory $actionFactory |
|
38 | + */ |
|
39 | + public function __construct(IActionFactory $actionFactory) { |
|
40 | + $this->actionFactory = $actionFactory; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @param IEntry $entry |
|
45 | + */ |
|
46 | + public function process(IEntry $entry) { |
|
47 | + foreach ($entry->getEMailAddresses() as $address) { |
|
48 | + // TODO: absolute path |
|
49 | + // TODO: meaningful URL |
|
50 | + // TODO: l10n |
|
51 | + $action = $this->actionFactory->newEMailAction('icon-mail', 'Mail', $address); |
|
52 | + $entry->addAction($action); |
|
53 | + } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | } |
@@ -29,123 +29,123 @@ |
||
29 | 29 | |
30 | 30 | class Entry implements IEntry { |
31 | 31 | |
32 | - /** @var string|int|null */ |
|
33 | - private $id = null; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $fullName = ''; |
|
37 | - |
|
38 | - /** @var string[] */ |
|
39 | - private $emailAddresses = []; |
|
40 | - |
|
41 | - /** @var IAction[] */ |
|
42 | - private $actions = []; |
|
43 | - |
|
44 | - /** @var array */ |
|
45 | - private $properties = []; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param string $id |
|
49 | - */ |
|
50 | - public function setId($id) { |
|
51 | - $this->id = $id; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param string $displayName |
|
56 | - */ |
|
57 | - public function setFullName($displayName) { |
|
58 | - $this->fullName = $displayName; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function getFullName() { |
|
65 | - return $this->fullName; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @param string $address |
|
70 | - */ |
|
71 | - public function addEMailAddress($address) { |
|
72 | - $this->emailAddresses[] = $address; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function getEMailAddresses() { |
|
79 | - return $this->emailAddresses; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @param IAction $action |
|
84 | - */ |
|
85 | - public function addAction(IAction $action) { |
|
86 | - $this->actions[] = $action; |
|
87 | - $this->sortActions(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @return IAction[] |
|
92 | - */ |
|
93 | - public function getActions() { |
|
94 | - return $this->actions; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * sort the actions by priority and name |
|
99 | - */ |
|
100 | - private function sortActions() { |
|
101 | - usort($this->actions, function(IAction $action1, IAction $action2) { |
|
102 | - $prio1 = $action1->getPriority(); |
|
103 | - $prio2 = $action2->getPriority(); |
|
104 | - |
|
105 | - if ($prio1 === $prio2) { |
|
106 | - // Ascending order for same priority |
|
107 | - return strcasecmp($action1->getName(), $action2->getName()); |
|
108 | - } |
|
109 | - |
|
110 | - // Descending order when priority differs |
|
111 | - return $prio2 - $prio1; |
|
112 | - }); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @param array $contact key-value array containing additional properties |
|
117 | - */ |
|
118 | - public function setProperties(array $contact) { |
|
119 | - $this->properties = $contact; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $key |
|
124 | - * @return mixed |
|
125 | - */ |
|
126 | - public function getProperty($key) { |
|
127 | - if (!isset($this->properties[$key])) { |
|
128 | - return null; |
|
129 | - } |
|
130 | - return $this->properties[$key]; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - public function jsonSerialize() { |
|
137 | - $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
138 | - $otherActions = array_map(function(IAction $action) { |
|
139 | - return $action->jsonSerialize(); |
|
140 | - }, array_slice($this->actions, 1)); |
|
141 | - |
|
142 | - return [ |
|
143 | - 'id' => $this->id, |
|
144 | - 'fullName' => $this->fullName, |
|
145 | - 'topAction' => $topAction, |
|
146 | - 'actions' => $otherActions, |
|
147 | - 'lastMessage' => '', |
|
148 | - ]; |
|
149 | - } |
|
32 | + /** @var string|int|null */ |
|
33 | + private $id = null; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $fullName = ''; |
|
37 | + |
|
38 | + /** @var string[] */ |
|
39 | + private $emailAddresses = []; |
|
40 | + |
|
41 | + /** @var IAction[] */ |
|
42 | + private $actions = []; |
|
43 | + |
|
44 | + /** @var array */ |
|
45 | + private $properties = []; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param string $id |
|
49 | + */ |
|
50 | + public function setId($id) { |
|
51 | + $this->id = $id; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param string $displayName |
|
56 | + */ |
|
57 | + public function setFullName($displayName) { |
|
58 | + $this->fullName = $displayName; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function getFullName() { |
|
65 | + return $this->fullName; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @param string $address |
|
70 | + */ |
|
71 | + public function addEMailAddress($address) { |
|
72 | + $this->emailAddresses[] = $address; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function getEMailAddresses() { |
|
79 | + return $this->emailAddresses; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @param IAction $action |
|
84 | + */ |
|
85 | + public function addAction(IAction $action) { |
|
86 | + $this->actions[] = $action; |
|
87 | + $this->sortActions(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @return IAction[] |
|
92 | + */ |
|
93 | + public function getActions() { |
|
94 | + return $this->actions; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * sort the actions by priority and name |
|
99 | + */ |
|
100 | + private function sortActions() { |
|
101 | + usort($this->actions, function(IAction $action1, IAction $action2) { |
|
102 | + $prio1 = $action1->getPriority(); |
|
103 | + $prio2 = $action2->getPriority(); |
|
104 | + |
|
105 | + if ($prio1 === $prio2) { |
|
106 | + // Ascending order for same priority |
|
107 | + return strcasecmp($action1->getName(), $action2->getName()); |
|
108 | + } |
|
109 | + |
|
110 | + // Descending order when priority differs |
|
111 | + return $prio2 - $prio1; |
|
112 | + }); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @param array $contact key-value array containing additional properties |
|
117 | + */ |
|
118 | + public function setProperties(array $contact) { |
|
119 | + $this->properties = $contact; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $key |
|
124 | + * @return mixed |
|
125 | + */ |
|
126 | + public function getProperty($key) { |
|
127 | + if (!isset($this->properties[$key])) { |
|
128 | + return null; |
|
129 | + } |
|
130 | + return $this->properties[$key]; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + public function jsonSerialize() { |
|
137 | + $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
138 | + $otherActions = array_map(function(IAction $action) { |
|
139 | + return $action->jsonSerialize(); |
|
140 | + }, array_slice($this->actions, 1)); |
|
141 | + |
|
142 | + return [ |
|
143 | + 'id' => $this->id, |
|
144 | + 'fullName' => $this->fullName, |
|
145 | + 'topAction' => $topAction, |
|
146 | + 'actions' => $otherActions, |
|
147 | + 'lastMessage' => '', |
|
148 | + ]; |
|
149 | + } |
|
150 | 150 | |
151 | 151 | } |
@@ -111,1482 +111,1482 @@ |
||
111 | 111 | * TODO: hookup all manager classes |
112 | 112 | */ |
113 | 113 | class Server extends ServerContainer implements IServerContainer { |
114 | - /** @var string */ |
|
115 | - private $webRoot; |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $webRoot |
|
119 | - * @param \OC\Config $config |
|
120 | - */ |
|
121 | - public function __construct($webRoot, \OC\Config $config) { |
|
122 | - parent::__construct(); |
|
123 | - $this->webRoot = $webRoot; |
|
124 | - |
|
125 | - $this->registerService('ContactsManager', function ($c) { |
|
126 | - return new ContactsManager(); |
|
127 | - }); |
|
128 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
129 | - |
|
130 | - $this->registerService('PreviewManager', function (Server $c) { |
|
131 | - return new PreviewManager( |
|
132 | - $c->getConfig(), |
|
133 | - $c->getRootFolder(), |
|
134 | - $c->getAppDataDir('preview'), |
|
135 | - $c->getEventDispatcher(), |
|
136 | - $c->getSession()->get('user_id') |
|
137 | - ); |
|
138 | - }); |
|
139 | - |
|
140 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
141 | - return new \OC\Preview\Watcher( |
|
142 | - $c->getAppDataDir('preview') |
|
143 | - ); |
|
144 | - }); |
|
145 | - |
|
146 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
147 | - $view = new View(); |
|
148 | - $util = new Encryption\Util( |
|
149 | - $view, |
|
150 | - $c->getUserManager(), |
|
151 | - $c->getGroupManager(), |
|
152 | - $c->getConfig() |
|
153 | - ); |
|
154 | - return new Encryption\Manager( |
|
155 | - $c->getConfig(), |
|
156 | - $c->getLogger(), |
|
157 | - $c->getL10N('core'), |
|
158 | - new View(), |
|
159 | - $util, |
|
160 | - new ArrayCache() |
|
161 | - ); |
|
162 | - }); |
|
163 | - |
|
164 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
165 | - $util = new Encryption\Util( |
|
166 | - new View(), |
|
167 | - $c->getUserManager(), |
|
168 | - $c->getGroupManager(), |
|
169 | - $c->getConfig() |
|
170 | - ); |
|
171 | - return new Encryption\File($util); |
|
172 | - }); |
|
173 | - |
|
174 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
175 | - $view = new View(); |
|
176 | - $util = new Encryption\Util( |
|
177 | - $view, |
|
178 | - $c->getUserManager(), |
|
179 | - $c->getGroupManager(), |
|
180 | - $c->getConfig() |
|
181 | - ); |
|
182 | - |
|
183 | - return new Encryption\Keys\Storage($view, $util); |
|
184 | - }); |
|
185 | - $this->registerService('TagMapper', function (Server $c) { |
|
186 | - return new TagMapper($c->getDatabaseConnection()); |
|
187 | - }); |
|
188 | - $this->registerService('TagManager', function (Server $c) { |
|
189 | - $tagMapper = $c->query('TagMapper'); |
|
190 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
191 | - }); |
|
192 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
193 | - $config = $c->getConfig(); |
|
194 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
195 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
196 | - $factory = new $factoryClass($this); |
|
197 | - return $factory; |
|
198 | - }); |
|
199 | - $this->registerService('SystemTagManager', function (Server $c) { |
|
200 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
201 | - }); |
|
202 | - $this->registerService('SystemTagObjectMapper', function (Server $c) { |
|
203 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
204 | - }); |
|
205 | - $this->registerService('RootFolder', function (Server $c) { |
|
206 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
207 | - $view = new View(); |
|
208 | - $root = new Root( |
|
209 | - $manager, |
|
210 | - $view, |
|
211 | - null, |
|
212 | - $c->getUserMountCache(), |
|
213 | - $this->getLogger(), |
|
214 | - $this->getUserManager() |
|
215 | - ); |
|
216 | - $connector = new HookConnector($root, $view); |
|
217 | - $connector->viewToNode(); |
|
218 | - |
|
219 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
220 | - $previewConnector->connectWatcher(); |
|
221 | - |
|
222 | - return $root; |
|
223 | - }); |
|
224 | - $this->registerService('LazyRootFolder', function(Server $c) { |
|
225 | - return new LazyRoot(function() use ($c) { |
|
226 | - return $c->query('RootFolder'); |
|
227 | - }); |
|
228 | - }); |
|
229 | - $this->registerService('UserManager', function (Server $c) { |
|
230 | - $config = $c->getConfig(); |
|
231 | - return new \OC\User\Manager($config); |
|
232 | - }); |
|
233 | - $this->registerService('GroupManager', function (Server $c) { |
|
234 | - $groupManager = new \OC\Group\Manager($this->getUserManager()); |
|
235 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
236 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
237 | - }); |
|
238 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
239 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
240 | - }); |
|
241 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
242 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
243 | - }); |
|
244 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
245 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
246 | - }); |
|
247 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
248 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
249 | - }); |
|
250 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
251 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
252 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
253 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
254 | - }); |
|
255 | - return $groupManager; |
|
256 | - }); |
|
257 | - $this->registerService(Store::class, function(Server $c) { |
|
258 | - $session = $c->getSession(); |
|
259 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
260 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
261 | - } else { |
|
262 | - $tokenProvider = null; |
|
263 | - } |
|
264 | - $logger = $c->getLogger(); |
|
265 | - return new Store($session, $logger, $tokenProvider); |
|
266 | - }); |
|
267 | - $this->registerAlias(IStore::class, Store::class); |
|
268 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
269 | - $dbConnection = $c->getDatabaseConnection(); |
|
270 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
271 | - }); |
|
272 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
273 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
274 | - $crypto = $c->getCrypto(); |
|
275 | - $config = $c->getConfig(); |
|
276 | - $logger = $c->getLogger(); |
|
277 | - $timeFactory = new TimeFactory(); |
|
278 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
279 | - }); |
|
280 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
281 | - $this->registerService('UserSession', function (Server $c) { |
|
282 | - $manager = $c->getUserManager(); |
|
283 | - $session = new \OC\Session\Memory(''); |
|
284 | - $timeFactory = new TimeFactory(); |
|
285 | - // Token providers might require a working database. This code |
|
286 | - // might however be called when ownCloud is not yet setup. |
|
287 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
288 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
289 | - } else { |
|
290 | - $defaultTokenProvider = null; |
|
291 | - } |
|
292 | - |
|
293 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
294 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
295 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
296 | - }); |
|
297 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
298 | - /** @var $user \OC\User\User */ |
|
299 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
300 | - }); |
|
301 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
302 | - /** @var $user \OC\User\User */ |
|
303 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
304 | - }); |
|
305 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
306 | - /** @var $user \OC\User\User */ |
|
307 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
308 | - }); |
|
309 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
310 | - /** @var $user \OC\User\User */ |
|
311 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
312 | - }); |
|
313 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
314 | - /** @var $user \OC\User\User */ |
|
315 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
316 | - }); |
|
317 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
318 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
319 | - }); |
|
320 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
321 | - /** @var $user \OC\User\User */ |
|
322 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
323 | - }); |
|
324 | - $userSession->listen('\OC\User', 'logout', function () { |
|
325 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
326 | - }); |
|
327 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
328 | - /** @var $user \OC\User\User */ |
|
329 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
330 | - }); |
|
331 | - return $userSession; |
|
332 | - }); |
|
333 | - |
|
334 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
335 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
336 | - }); |
|
337 | - |
|
338 | - $this->registerService('NavigationManager', function (Server $c) { |
|
339 | - return new \OC\NavigationManager($c->getAppManager(), |
|
340 | - $c->getURLGenerator(), |
|
341 | - $c->getL10NFactory(), |
|
342 | - $c->getUserSession(), |
|
343 | - $c->getGroupManager()); |
|
344 | - }); |
|
345 | - $this->registerService('AllConfig', function (Server $c) { |
|
346 | - return new \OC\AllConfig( |
|
347 | - $c->getSystemConfig() |
|
348 | - ); |
|
349 | - }); |
|
350 | - $this->registerAlias(\OCP\IConfig::class, 'AllConfig'); |
|
351 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
352 | - return new \OC\SystemConfig($config); |
|
353 | - }); |
|
354 | - $this->registerService('AppConfig', function (Server $c) { |
|
355 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
356 | - }); |
|
357 | - $this->registerService('L10NFactory', function (Server $c) { |
|
358 | - return new \OC\L10N\Factory( |
|
359 | - $c->getConfig(), |
|
360 | - $c->getRequest(), |
|
361 | - $c->getUserSession(), |
|
362 | - \OC::$SERVERROOT |
|
363 | - ); |
|
364 | - }); |
|
365 | - $this->registerService('URLGenerator', function (Server $c) { |
|
366 | - $config = $c->getConfig(); |
|
367 | - $cacheFactory = $c->getMemCacheFactory(); |
|
368 | - return new \OC\URLGenerator( |
|
369 | - $config, |
|
370 | - $cacheFactory |
|
371 | - ); |
|
372 | - }); |
|
373 | - $this->registerAlias(IURLGenerator::class, 'URLGenerator'); |
|
374 | - $this->registerService('AppHelper', function ($c) { |
|
375 | - return new \OC\AppHelper(); |
|
376 | - }); |
|
377 | - $this->registerService('AppFetcher', function ($c) { |
|
378 | - return new AppFetcher( |
|
379 | - $this->getAppDataDir('appstore'), |
|
380 | - $this->getHTTPClientService(), |
|
381 | - $this->query(TimeFactory::class), |
|
382 | - $this->getConfig() |
|
383 | - ); |
|
384 | - }); |
|
385 | - $this->registerService('CategoryFetcher', function ($c) { |
|
386 | - return new CategoryFetcher( |
|
387 | - $this->getAppDataDir('appstore'), |
|
388 | - $this->getHTTPClientService(), |
|
389 | - $this->query(TimeFactory::class), |
|
390 | - $this->getConfig() |
|
391 | - ); |
|
392 | - }); |
|
393 | - $this->registerService('UserCache', function ($c) { |
|
394 | - return new Cache\File(); |
|
395 | - }); |
|
396 | - $this->registerService('MemCacheFactory', function (Server $c) { |
|
397 | - $config = $c->getConfig(); |
|
398 | - |
|
399 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
400 | - $v = \OC_App::getAppVersions(); |
|
401 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
402 | - $version = implode(',', $v); |
|
403 | - $instanceId = \OC_Util::getInstanceId(); |
|
404 | - $path = \OC::$SERVERROOT; |
|
405 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
406 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
407 | - $config->getSystemValue('memcache.local', null), |
|
408 | - $config->getSystemValue('memcache.distributed', null), |
|
409 | - $config->getSystemValue('memcache.locking', null) |
|
410 | - ); |
|
411 | - } |
|
412 | - |
|
413 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
414 | - '\\OC\\Memcache\\ArrayCache', |
|
415 | - '\\OC\\Memcache\\ArrayCache', |
|
416 | - '\\OC\\Memcache\\ArrayCache' |
|
417 | - ); |
|
418 | - }); |
|
419 | - $this->registerService('RedisFactory', function (Server $c) { |
|
420 | - $systemConfig = $c->getSystemConfig(); |
|
421 | - return new RedisFactory($systemConfig); |
|
422 | - }); |
|
423 | - $this->registerService('ActivityManager', function (Server $c) { |
|
424 | - return new \OC\Activity\Manager( |
|
425 | - $c->getRequest(), |
|
426 | - $c->getUserSession(), |
|
427 | - $c->getConfig(), |
|
428 | - $c->query(IValidator::class) |
|
429 | - ); |
|
430 | - }); |
|
431 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
432 | - return new \OC\Activity\EventMerger( |
|
433 | - $c->getL10N('lib') |
|
434 | - ); |
|
435 | - }); |
|
436 | - $this->registerAlias(IValidator::class, Validator::class); |
|
437 | - $this->registerService('AvatarManager', function (Server $c) { |
|
438 | - return new AvatarManager( |
|
439 | - $c->getUserManager(), |
|
440 | - $c->getAppDataDir('avatar'), |
|
441 | - $c->getL10N('lib'), |
|
442 | - $c->getLogger(), |
|
443 | - $c->getConfig() |
|
444 | - ); |
|
445 | - }); |
|
446 | - $this->registerService('Logger', function (Server $c) { |
|
447 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
448 | - $logger = Log::getLogClass($logType); |
|
449 | - call_user_func(array($logger, 'init')); |
|
450 | - |
|
451 | - return new Log($logger); |
|
452 | - }); |
|
453 | - $this->registerService('JobList', function (Server $c) { |
|
454 | - $config = $c->getConfig(); |
|
455 | - return new \OC\BackgroundJob\JobList( |
|
456 | - $c->getDatabaseConnection(), |
|
457 | - $config, |
|
458 | - new TimeFactory() |
|
459 | - ); |
|
460 | - }); |
|
461 | - $this->registerService('Router', function (Server $c) { |
|
462 | - $cacheFactory = $c->getMemCacheFactory(); |
|
463 | - $logger = $c->getLogger(); |
|
464 | - if ($cacheFactory->isAvailable()) { |
|
465 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
466 | - } else { |
|
467 | - $router = new \OC\Route\Router($logger); |
|
468 | - } |
|
469 | - return $router; |
|
470 | - }); |
|
471 | - $this->registerService('Search', function ($c) { |
|
472 | - return new Search(); |
|
473 | - }); |
|
474 | - $this->registerService('SecureRandom', function ($c) { |
|
475 | - return new SecureRandom(); |
|
476 | - }); |
|
477 | - $this->registerService('Crypto', function (Server $c) { |
|
478 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
479 | - }); |
|
480 | - $this->registerService('Hasher', function (Server $c) { |
|
481 | - return new Hasher($c->getConfig()); |
|
482 | - }); |
|
483 | - $this->registerService('CredentialsManager', function (Server $c) { |
|
484 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
485 | - }); |
|
486 | - $this->registerService('DatabaseConnection', function (Server $c) { |
|
487 | - $systemConfig = $c->getSystemConfig(); |
|
488 | - $factory = new \OC\DB\ConnectionFactory($c->getConfig()); |
|
489 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
490 | - if (!$factory->isValidType($type)) { |
|
491 | - throw new \OC\DatabaseException('Invalid database type'); |
|
492 | - } |
|
493 | - $connectionParams = $factory->createConnectionParams($systemConfig); |
|
494 | - $connection = $factory->getConnection($type, $connectionParams); |
|
495 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
496 | - return $connection; |
|
497 | - }); |
|
498 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
499 | - $config = $c->getConfig(); |
|
500 | - return new HTTPHelper( |
|
501 | - $config, |
|
502 | - $c->getHTTPClientService() |
|
503 | - ); |
|
504 | - }); |
|
505 | - $this->registerService('HttpClientService', function (Server $c) { |
|
506 | - $user = \OC_User::getUser(); |
|
507 | - $uid = $user ? $user : null; |
|
508 | - return new ClientService( |
|
509 | - $c->getConfig(), |
|
510 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
511 | - ); |
|
512 | - }); |
|
513 | - $this->registerService('EventLogger', function (Server $c) { |
|
514 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
515 | - return new EventLogger(); |
|
516 | - } else { |
|
517 | - return new NullEventLogger(); |
|
518 | - } |
|
519 | - }); |
|
520 | - $this->registerService('QueryLogger', function (Server $c) { |
|
521 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
522 | - return new QueryLogger(); |
|
523 | - } else { |
|
524 | - return new NullQueryLogger(); |
|
525 | - } |
|
526 | - }); |
|
527 | - $this->registerService('TempManager', function (Server $c) { |
|
528 | - return new TempManager( |
|
529 | - $c->getLogger(), |
|
530 | - $c->getConfig() |
|
531 | - ); |
|
532 | - }); |
|
533 | - $this->registerService('AppManager', function (Server $c) { |
|
534 | - return new \OC\App\AppManager( |
|
535 | - $c->getUserSession(), |
|
536 | - $c->getAppConfig(), |
|
537 | - $c->getGroupManager(), |
|
538 | - $c->getMemCacheFactory(), |
|
539 | - $c->getEventDispatcher() |
|
540 | - ); |
|
541 | - }); |
|
542 | - $this->registerService('DateTimeZone', function (Server $c) { |
|
543 | - return new DateTimeZone( |
|
544 | - $c->getConfig(), |
|
545 | - $c->getSession() |
|
546 | - ); |
|
547 | - }); |
|
548 | - $this->registerService('DateTimeFormatter', function (Server $c) { |
|
549 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
550 | - |
|
551 | - return new DateTimeFormatter( |
|
552 | - $c->getDateTimeZone()->getTimeZone(), |
|
553 | - $c->getL10N('lib', $language) |
|
554 | - ); |
|
555 | - }); |
|
556 | - $this->registerService('UserMountCache', function (Server $c) { |
|
557 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
558 | - $listener = new UserMountCacheListener($mountCache); |
|
559 | - $listener->listen($c->getUserManager()); |
|
560 | - return $mountCache; |
|
561 | - }); |
|
562 | - $this->registerService('MountConfigManager', function (Server $c) { |
|
563 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
564 | - $mountCache = $c->query('UserMountCache'); |
|
565 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
566 | - |
|
567 | - // builtin providers |
|
568 | - |
|
569 | - $config = $c->getConfig(); |
|
570 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
571 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
572 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
573 | - |
|
574 | - return $manager; |
|
575 | - }); |
|
576 | - $this->registerService('IniWrapper', function ($c) { |
|
577 | - return new IniGetWrapper(); |
|
578 | - }); |
|
579 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
580 | - $jobList = $c->getJobList(); |
|
581 | - return new AsyncBus($jobList); |
|
582 | - }); |
|
583 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
584 | - return new TrustedDomainHelper($this->getConfig()); |
|
585 | - }); |
|
586 | - $this->registerService('Throttler', function(Server $c) { |
|
587 | - return new Throttler( |
|
588 | - $c->getDatabaseConnection(), |
|
589 | - new TimeFactory(), |
|
590 | - $c->getLogger(), |
|
591 | - $c->getConfig() |
|
592 | - ); |
|
593 | - }); |
|
594 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
595 | - // IConfig and IAppManager requires a working database. This code |
|
596 | - // might however be called when ownCloud is not yet setup. |
|
597 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
598 | - $config = $c->getConfig(); |
|
599 | - $appManager = $c->getAppManager(); |
|
600 | - } else { |
|
601 | - $config = null; |
|
602 | - $appManager = null; |
|
603 | - } |
|
604 | - |
|
605 | - return new Checker( |
|
606 | - new EnvironmentHelper(), |
|
607 | - new FileAccessHelper(), |
|
608 | - new AppLocator(), |
|
609 | - $config, |
|
610 | - $c->getMemCacheFactory(), |
|
611 | - $appManager, |
|
612 | - $c->getTempManager() |
|
613 | - ); |
|
614 | - }); |
|
615 | - $this->registerService('Request', function ($c) { |
|
616 | - if (isset($this['urlParams'])) { |
|
617 | - $urlParams = $this['urlParams']; |
|
618 | - } else { |
|
619 | - $urlParams = []; |
|
620 | - } |
|
621 | - |
|
622 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
623 | - && in_array('fakeinput', stream_get_wrappers()) |
|
624 | - ) { |
|
625 | - $stream = 'fakeinput://data'; |
|
626 | - } else { |
|
627 | - $stream = 'php://input'; |
|
628 | - } |
|
629 | - |
|
630 | - return new Request( |
|
631 | - [ |
|
632 | - 'get' => $_GET, |
|
633 | - 'post' => $_POST, |
|
634 | - 'files' => $_FILES, |
|
635 | - 'server' => $_SERVER, |
|
636 | - 'env' => $_ENV, |
|
637 | - 'cookies' => $_COOKIE, |
|
638 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
639 | - ? $_SERVER['REQUEST_METHOD'] |
|
640 | - : null, |
|
641 | - 'urlParams' => $urlParams, |
|
642 | - ], |
|
643 | - $this->getSecureRandom(), |
|
644 | - $this->getConfig(), |
|
645 | - $this->getCsrfTokenManager(), |
|
646 | - $stream |
|
647 | - ); |
|
648 | - }); |
|
649 | - $this->registerService('Mailer', function (Server $c) { |
|
650 | - return new Mailer( |
|
651 | - $c->getConfig(), |
|
652 | - $c->getLogger(), |
|
653 | - $c->getThemingDefaults() |
|
654 | - ); |
|
655 | - }); |
|
656 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
657 | - $config = $c->getConfig(); |
|
658 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
659 | - if(is_null($factoryClass)) { |
|
660 | - throw new \Exception('ldapProviderFactory not set'); |
|
661 | - } |
|
662 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
663 | - $factory = new $factoryClass($this); |
|
664 | - return $factory->getLDAPProvider(); |
|
665 | - }); |
|
666 | - $this->registerService('LockingProvider', function (Server $c) { |
|
667 | - $ini = $c->getIniWrapper(); |
|
668 | - $config = $c->getConfig(); |
|
669 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
670 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
671 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
672 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
673 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
674 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
675 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
676 | - } |
|
677 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
678 | - } |
|
679 | - return new NoopLockingProvider(); |
|
680 | - }); |
|
681 | - $this->registerService('MountManager', function () { |
|
682 | - return new \OC\Files\Mount\Manager(); |
|
683 | - }); |
|
684 | - $this->registerService('MimeTypeDetector', function (Server $c) { |
|
685 | - return new \OC\Files\Type\Detection( |
|
686 | - $c->getURLGenerator(), |
|
687 | - \OC::$configDir, |
|
688 | - \OC::$SERVERROOT . '/resources/config/' |
|
689 | - ); |
|
690 | - }); |
|
691 | - $this->registerService('MimeTypeLoader', function (Server $c) { |
|
692 | - return new \OC\Files\Type\Loader( |
|
693 | - $c->getDatabaseConnection() |
|
694 | - ); |
|
695 | - }); |
|
696 | - $this->registerService('NotificationManager', function (Server $c) { |
|
697 | - return new Manager( |
|
698 | - $c->query(IValidator::class) |
|
699 | - ); |
|
700 | - }); |
|
701 | - $this->registerService('CapabilitiesManager', function (Server $c) { |
|
702 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
703 | - $manager->registerCapability(function () use ($c) { |
|
704 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
705 | - }); |
|
706 | - return $manager; |
|
707 | - }); |
|
708 | - $this->registerService('CommentsManager', function(Server $c) { |
|
709 | - $config = $c->getConfig(); |
|
710 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
711 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
712 | - $factory = new $factoryClass($this); |
|
713 | - return $factory->getManager(); |
|
714 | - }); |
|
715 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
716 | - /* |
|
114 | + /** @var string */ |
|
115 | + private $webRoot; |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $webRoot |
|
119 | + * @param \OC\Config $config |
|
120 | + */ |
|
121 | + public function __construct($webRoot, \OC\Config $config) { |
|
122 | + parent::__construct(); |
|
123 | + $this->webRoot = $webRoot; |
|
124 | + |
|
125 | + $this->registerService('ContactsManager', function ($c) { |
|
126 | + return new ContactsManager(); |
|
127 | + }); |
|
128 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
129 | + |
|
130 | + $this->registerService('PreviewManager', function (Server $c) { |
|
131 | + return new PreviewManager( |
|
132 | + $c->getConfig(), |
|
133 | + $c->getRootFolder(), |
|
134 | + $c->getAppDataDir('preview'), |
|
135 | + $c->getEventDispatcher(), |
|
136 | + $c->getSession()->get('user_id') |
|
137 | + ); |
|
138 | + }); |
|
139 | + |
|
140 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
141 | + return new \OC\Preview\Watcher( |
|
142 | + $c->getAppDataDir('preview') |
|
143 | + ); |
|
144 | + }); |
|
145 | + |
|
146 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
147 | + $view = new View(); |
|
148 | + $util = new Encryption\Util( |
|
149 | + $view, |
|
150 | + $c->getUserManager(), |
|
151 | + $c->getGroupManager(), |
|
152 | + $c->getConfig() |
|
153 | + ); |
|
154 | + return new Encryption\Manager( |
|
155 | + $c->getConfig(), |
|
156 | + $c->getLogger(), |
|
157 | + $c->getL10N('core'), |
|
158 | + new View(), |
|
159 | + $util, |
|
160 | + new ArrayCache() |
|
161 | + ); |
|
162 | + }); |
|
163 | + |
|
164 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
165 | + $util = new Encryption\Util( |
|
166 | + new View(), |
|
167 | + $c->getUserManager(), |
|
168 | + $c->getGroupManager(), |
|
169 | + $c->getConfig() |
|
170 | + ); |
|
171 | + return new Encryption\File($util); |
|
172 | + }); |
|
173 | + |
|
174 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
175 | + $view = new View(); |
|
176 | + $util = new Encryption\Util( |
|
177 | + $view, |
|
178 | + $c->getUserManager(), |
|
179 | + $c->getGroupManager(), |
|
180 | + $c->getConfig() |
|
181 | + ); |
|
182 | + |
|
183 | + return new Encryption\Keys\Storage($view, $util); |
|
184 | + }); |
|
185 | + $this->registerService('TagMapper', function (Server $c) { |
|
186 | + return new TagMapper($c->getDatabaseConnection()); |
|
187 | + }); |
|
188 | + $this->registerService('TagManager', function (Server $c) { |
|
189 | + $tagMapper = $c->query('TagMapper'); |
|
190 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
191 | + }); |
|
192 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
193 | + $config = $c->getConfig(); |
|
194 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
195 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
196 | + $factory = new $factoryClass($this); |
|
197 | + return $factory; |
|
198 | + }); |
|
199 | + $this->registerService('SystemTagManager', function (Server $c) { |
|
200 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
201 | + }); |
|
202 | + $this->registerService('SystemTagObjectMapper', function (Server $c) { |
|
203 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
204 | + }); |
|
205 | + $this->registerService('RootFolder', function (Server $c) { |
|
206 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
207 | + $view = new View(); |
|
208 | + $root = new Root( |
|
209 | + $manager, |
|
210 | + $view, |
|
211 | + null, |
|
212 | + $c->getUserMountCache(), |
|
213 | + $this->getLogger(), |
|
214 | + $this->getUserManager() |
|
215 | + ); |
|
216 | + $connector = new HookConnector($root, $view); |
|
217 | + $connector->viewToNode(); |
|
218 | + |
|
219 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
220 | + $previewConnector->connectWatcher(); |
|
221 | + |
|
222 | + return $root; |
|
223 | + }); |
|
224 | + $this->registerService('LazyRootFolder', function(Server $c) { |
|
225 | + return new LazyRoot(function() use ($c) { |
|
226 | + return $c->query('RootFolder'); |
|
227 | + }); |
|
228 | + }); |
|
229 | + $this->registerService('UserManager', function (Server $c) { |
|
230 | + $config = $c->getConfig(); |
|
231 | + return new \OC\User\Manager($config); |
|
232 | + }); |
|
233 | + $this->registerService('GroupManager', function (Server $c) { |
|
234 | + $groupManager = new \OC\Group\Manager($this->getUserManager()); |
|
235 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
236 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
237 | + }); |
|
238 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
239 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
240 | + }); |
|
241 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
242 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
243 | + }); |
|
244 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
245 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
246 | + }); |
|
247 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
248 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
249 | + }); |
|
250 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
251 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
252 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
253 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
254 | + }); |
|
255 | + return $groupManager; |
|
256 | + }); |
|
257 | + $this->registerService(Store::class, function(Server $c) { |
|
258 | + $session = $c->getSession(); |
|
259 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
260 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
261 | + } else { |
|
262 | + $tokenProvider = null; |
|
263 | + } |
|
264 | + $logger = $c->getLogger(); |
|
265 | + return new Store($session, $logger, $tokenProvider); |
|
266 | + }); |
|
267 | + $this->registerAlias(IStore::class, Store::class); |
|
268 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
269 | + $dbConnection = $c->getDatabaseConnection(); |
|
270 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
271 | + }); |
|
272 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
273 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
274 | + $crypto = $c->getCrypto(); |
|
275 | + $config = $c->getConfig(); |
|
276 | + $logger = $c->getLogger(); |
|
277 | + $timeFactory = new TimeFactory(); |
|
278 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
279 | + }); |
|
280 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
281 | + $this->registerService('UserSession', function (Server $c) { |
|
282 | + $manager = $c->getUserManager(); |
|
283 | + $session = new \OC\Session\Memory(''); |
|
284 | + $timeFactory = new TimeFactory(); |
|
285 | + // Token providers might require a working database. This code |
|
286 | + // might however be called when ownCloud is not yet setup. |
|
287 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
288 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
289 | + } else { |
|
290 | + $defaultTokenProvider = null; |
|
291 | + } |
|
292 | + |
|
293 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
294 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
295 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
296 | + }); |
|
297 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
298 | + /** @var $user \OC\User\User */ |
|
299 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
300 | + }); |
|
301 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
302 | + /** @var $user \OC\User\User */ |
|
303 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
304 | + }); |
|
305 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
306 | + /** @var $user \OC\User\User */ |
|
307 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
308 | + }); |
|
309 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
310 | + /** @var $user \OC\User\User */ |
|
311 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
312 | + }); |
|
313 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
314 | + /** @var $user \OC\User\User */ |
|
315 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
316 | + }); |
|
317 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
318 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
319 | + }); |
|
320 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
321 | + /** @var $user \OC\User\User */ |
|
322 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
323 | + }); |
|
324 | + $userSession->listen('\OC\User', 'logout', function () { |
|
325 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
326 | + }); |
|
327 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
328 | + /** @var $user \OC\User\User */ |
|
329 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
330 | + }); |
|
331 | + return $userSession; |
|
332 | + }); |
|
333 | + |
|
334 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
335 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
336 | + }); |
|
337 | + |
|
338 | + $this->registerService('NavigationManager', function (Server $c) { |
|
339 | + return new \OC\NavigationManager($c->getAppManager(), |
|
340 | + $c->getURLGenerator(), |
|
341 | + $c->getL10NFactory(), |
|
342 | + $c->getUserSession(), |
|
343 | + $c->getGroupManager()); |
|
344 | + }); |
|
345 | + $this->registerService('AllConfig', function (Server $c) { |
|
346 | + return new \OC\AllConfig( |
|
347 | + $c->getSystemConfig() |
|
348 | + ); |
|
349 | + }); |
|
350 | + $this->registerAlias(\OCP\IConfig::class, 'AllConfig'); |
|
351 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
352 | + return new \OC\SystemConfig($config); |
|
353 | + }); |
|
354 | + $this->registerService('AppConfig', function (Server $c) { |
|
355 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
356 | + }); |
|
357 | + $this->registerService('L10NFactory', function (Server $c) { |
|
358 | + return new \OC\L10N\Factory( |
|
359 | + $c->getConfig(), |
|
360 | + $c->getRequest(), |
|
361 | + $c->getUserSession(), |
|
362 | + \OC::$SERVERROOT |
|
363 | + ); |
|
364 | + }); |
|
365 | + $this->registerService('URLGenerator', function (Server $c) { |
|
366 | + $config = $c->getConfig(); |
|
367 | + $cacheFactory = $c->getMemCacheFactory(); |
|
368 | + return new \OC\URLGenerator( |
|
369 | + $config, |
|
370 | + $cacheFactory |
|
371 | + ); |
|
372 | + }); |
|
373 | + $this->registerAlias(IURLGenerator::class, 'URLGenerator'); |
|
374 | + $this->registerService('AppHelper', function ($c) { |
|
375 | + return new \OC\AppHelper(); |
|
376 | + }); |
|
377 | + $this->registerService('AppFetcher', function ($c) { |
|
378 | + return new AppFetcher( |
|
379 | + $this->getAppDataDir('appstore'), |
|
380 | + $this->getHTTPClientService(), |
|
381 | + $this->query(TimeFactory::class), |
|
382 | + $this->getConfig() |
|
383 | + ); |
|
384 | + }); |
|
385 | + $this->registerService('CategoryFetcher', function ($c) { |
|
386 | + return new CategoryFetcher( |
|
387 | + $this->getAppDataDir('appstore'), |
|
388 | + $this->getHTTPClientService(), |
|
389 | + $this->query(TimeFactory::class), |
|
390 | + $this->getConfig() |
|
391 | + ); |
|
392 | + }); |
|
393 | + $this->registerService('UserCache', function ($c) { |
|
394 | + return new Cache\File(); |
|
395 | + }); |
|
396 | + $this->registerService('MemCacheFactory', function (Server $c) { |
|
397 | + $config = $c->getConfig(); |
|
398 | + |
|
399 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
400 | + $v = \OC_App::getAppVersions(); |
|
401 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
402 | + $version = implode(',', $v); |
|
403 | + $instanceId = \OC_Util::getInstanceId(); |
|
404 | + $path = \OC::$SERVERROOT; |
|
405 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
406 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
407 | + $config->getSystemValue('memcache.local', null), |
|
408 | + $config->getSystemValue('memcache.distributed', null), |
|
409 | + $config->getSystemValue('memcache.locking', null) |
|
410 | + ); |
|
411 | + } |
|
412 | + |
|
413 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
414 | + '\\OC\\Memcache\\ArrayCache', |
|
415 | + '\\OC\\Memcache\\ArrayCache', |
|
416 | + '\\OC\\Memcache\\ArrayCache' |
|
417 | + ); |
|
418 | + }); |
|
419 | + $this->registerService('RedisFactory', function (Server $c) { |
|
420 | + $systemConfig = $c->getSystemConfig(); |
|
421 | + return new RedisFactory($systemConfig); |
|
422 | + }); |
|
423 | + $this->registerService('ActivityManager', function (Server $c) { |
|
424 | + return new \OC\Activity\Manager( |
|
425 | + $c->getRequest(), |
|
426 | + $c->getUserSession(), |
|
427 | + $c->getConfig(), |
|
428 | + $c->query(IValidator::class) |
|
429 | + ); |
|
430 | + }); |
|
431 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
432 | + return new \OC\Activity\EventMerger( |
|
433 | + $c->getL10N('lib') |
|
434 | + ); |
|
435 | + }); |
|
436 | + $this->registerAlias(IValidator::class, Validator::class); |
|
437 | + $this->registerService('AvatarManager', function (Server $c) { |
|
438 | + return new AvatarManager( |
|
439 | + $c->getUserManager(), |
|
440 | + $c->getAppDataDir('avatar'), |
|
441 | + $c->getL10N('lib'), |
|
442 | + $c->getLogger(), |
|
443 | + $c->getConfig() |
|
444 | + ); |
|
445 | + }); |
|
446 | + $this->registerService('Logger', function (Server $c) { |
|
447 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
448 | + $logger = Log::getLogClass($logType); |
|
449 | + call_user_func(array($logger, 'init')); |
|
450 | + |
|
451 | + return new Log($logger); |
|
452 | + }); |
|
453 | + $this->registerService('JobList', function (Server $c) { |
|
454 | + $config = $c->getConfig(); |
|
455 | + return new \OC\BackgroundJob\JobList( |
|
456 | + $c->getDatabaseConnection(), |
|
457 | + $config, |
|
458 | + new TimeFactory() |
|
459 | + ); |
|
460 | + }); |
|
461 | + $this->registerService('Router', function (Server $c) { |
|
462 | + $cacheFactory = $c->getMemCacheFactory(); |
|
463 | + $logger = $c->getLogger(); |
|
464 | + if ($cacheFactory->isAvailable()) { |
|
465 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
466 | + } else { |
|
467 | + $router = new \OC\Route\Router($logger); |
|
468 | + } |
|
469 | + return $router; |
|
470 | + }); |
|
471 | + $this->registerService('Search', function ($c) { |
|
472 | + return new Search(); |
|
473 | + }); |
|
474 | + $this->registerService('SecureRandom', function ($c) { |
|
475 | + return new SecureRandom(); |
|
476 | + }); |
|
477 | + $this->registerService('Crypto', function (Server $c) { |
|
478 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
479 | + }); |
|
480 | + $this->registerService('Hasher', function (Server $c) { |
|
481 | + return new Hasher($c->getConfig()); |
|
482 | + }); |
|
483 | + $this->registerService('CredentialsManager', function (Server $c) { |
|
484 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
485 | + }); |
|
486 | + $this->registerService('DatabaseConnection', function (Server $c) { |
|
487 | + $systemConfig = $c->getSystemConfig(); |
|
488 | + $factory = new \OC\DB\ConnectionFactory($c->getConfig()); |
|
489 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
490 | + if (!$factory->isValidType($type)) { |
|
491 | + throw new \OC\DatabaseException('Invalid database type'); |
|
492 | + } |
|
493 | + $connectionParams = $factory->createConnectionParams($systemConfig); |
|
494 | + $connection = $factory->getConnection($type, $connectionParams); |
|
495 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
496 | + return $connection; |
|
497 | + }); |
|
498 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
499 | + $config = $c->getConfig(); |
|
500 | + return new HTTPHelper( |
|
501 | + $config, |
|
502 | + $c->getHTTPClientService() |
|
503 | + ); |
|
504 | + }); |
|
505 | + $this->registerService('HttpClientService', function (Server $c) { |
|
506 | + $user = \OC_User::getUser(); |
|
507 | + $uid = $user ? $user : null; |
|
508 | + return new ClientService( |
|
509 | + $c->getConfig(), |
|
510 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
511 | + ); |
|
512 | + }); |
|
513 | + $this->registerService('EventLogger', function (Server $c) { |
|
514 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
515 | + return new EventLogger(); |
|
516 | + } else { |
|
517 | + return new NullEventLogger(); |
|
518 | + } |
|
519 | + }); |
|
520 | + $this->registerService('QueryLogger', function (Server $c) { |
|
521 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
522 | + return new QueryLogger(); |
|
523 | + } else { |
|
524 | + return new NullQueryLogger(); |
|
525 | + } |
|
526 | + }); |
|
527 | + $this->registerService('TempManager', function (Server $c) { |
|
528 | + return new TempManager( |
|
529 | + $c->getLogger(), |
|
530 | + $c->getConfig() |
|
531 | + ); |
|
532 | + }); |
|
533 | + $this->registerService('AppManager', function (Server $c) { |
|
534 | + return new \OC\App\AppManager( |
|
535 | + $c->getUserSession(), |
|
536 | + $c->getAppConfig(), |
|
537 | + $c->getGroupManager(), |
|
538 | + $c->getMemCacheFactory(), |
|
539 | + $c->getEventDispatcher() |
|
540 | + ); |
|
541 | + }); |
|
542 | + $this->registerService('DateTimeZone', function (Server $c) { |
|
543 | + return new DateTimeZone( |
|
544 | + $c->getConfig(), |
|
545 | + $c->getSession() |
|
546 | + ); |
|
547 | + }); |
|
548 | + $this->registerService('DateTimeFormatter', function (Server $c) { |
|
549 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
550 | + |
|
551 | + return new DateTimeFormatter( |
|
552 | + $c->getDateTimeZone()->getTimeZone(), |
|
553 | + $c->getL10N('lib', $language) |
|
554 | + ); |
|
555 | + }); |
|
556 | + $this->registerService('UserMountCache', function (Server $c) { |
|
557 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
558 | + $listener = new UserMountCacheListener($mountCache); |
|
559 | + $listener->listen($c->getUserManager()); |
|
560 | + return $mountCache; |
|
561 | + }); |
|
562 | + $this->registerService('MountConfigManager', function (Server $c) { |
|
563 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
564 | + $mountCache = $c->query('UserMountCache'); |
|
565 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
566 | + |
|
567 | + // builtin providers |
|
568 | + |
|
569 | + $config = $c->getConfig(); |
|
570 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
571 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
572 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
573 | + |
|
574 | + return $manager; |
|
575 | + }); |
|
576 | + $this->registerService('IniWrapper', function ($c) { |
|
577 | + return new IniGetWrapper(); |
|
578 | + }); |
|
579 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
580 | + $jobList = $c->getJobList(); |
|
581 | + return new AsyncBus($jobList); |
|
582 | + }); |
|
583 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
584 | + return new TrustedDomainHelper($this->getConfig()); |
|
585 | + }); |
|
586 | + $this->registerService('Throttler', function(Server $c) { |
|
587 | + return new Throttler( |
|
588 | + $c->getDatabaseConnection(), |
|
589 | + new TimeFactory(), |
|
590 | + $c->getLogger(), |
|
591 | + $c->getConfig() |
|
592 | + ); |
|
593 | + }); |
|
594 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
595 | + // IConfig and IAppManager requires a working database. This code |
|
596 | + // might however be called when ownCloud is not yet setup. |
|
597 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
598 | + $config = $c->getConfig(); |
|
599 | + $appManager = $c->getAppManager(); |
|
600 | + } else { |
|
601 | + $config = null; |
|
602 | + $appManager = null; |
|
603 | + } |
|
604 | + |
|
605 | + return new Checker( |
|
606 | + new EnvironmentHelper(), |
|
607 | + new FileAccessHelper(), |
|
608 | + new AppLocator(), |
|
609 | + $config, |
|
610 | + $c->getMemCacheFactory(), |
|
611 | + $appManager, |
|
612 | + $c->getTempManager() |
|
613 | + ); |
|
614 | + }); |
|
615 | + $this->registerService('Request', function ($c) { |
|
616 | + if (isset($this['urlParams'])) { |
|
617 | + $urlParams = $this['urlParams']; |
|
618 | + } else { |
|
619 | + $urlParams = []; |
|
620 | + } |
|
621 | + |
|
622 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
623 | + && in_array('fakeinput', stream_get_wrappers()) |
|
624 | + ) { |
|
625 | + $stream = 'fakeinput://data'; |
|
626 | + } else { |
|
627 | + $stream = 'php://input'; |
|
628 | + } |
|
629 | + |
|
630 | + return new Request( |
|
631 | + [ |
|
632 | + 'get' => $_GET, |
|
633 | + 'post' => $_POST, |
|
634 | + 'files' => $_FILES, |
|
635 | + 'server' => $_SERVER, |
|
636 | + 'env' => $_ENV, |
|
637 | + 'cookies' => $_COOKIE, |
|
638 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
639 | + ? $_SERVER['REQUEST_METHOD'] |
|
640 | + : null, |
|
641 | + 'urlParams' => $urlParams, |
|
642 | + ], |
|
643 | + $this->getSecureRandom(), |
|
644 | + $this->getConfig(), |
|
645 | + $this->getCsrfTokenManager(), |
|
646 | + $stream |
|
647 | + ); |
|
648 | + }); |
|
649 | + $this->registerService('Mailer', function (Server $c) { |
|
650 | + return new Mailer( |
|
651 | + $c->getConfig(), |
|
652 | + $c->getLogger(), |
|
653 | + $c->getThemingDefaults() |
|
654 | + ); |
|
655 | + }); |
|
656 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
657 | + $config = $c->getConfig(); |
|
658 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
659 | + if(is_null($factoryClass)) { |
|
660 | + throw new \Exception('ldapProviderFactory not set'); |
|
661 | + } |
|
662 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
663 | + $factory = new $factoryClass($this); |
|
664 | + return $factory->getLDAPProvider(); |
|
665 | + }); |
|
666 | + $this->registerService('LockingProvider', function (Server $c) { |
|
667 | + $ini = $c->getIniWrapper(); |
|
668 | + $config = $c->getConfig(); |
|
669 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
670 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
671 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
672 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
673 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
674 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
675 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
676 | + } |
|
677 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
678 | + } |
|
679 | + return new NoopLockingProvider(); |
|
680 | + }); |
|
681 | + $this->registerService('MountManager', function () { |
|
682 | + return new \OC\Files\Mount\Manager(); |
|
683 | + }); |
|
684 | + $this->registerService('MimeTypeDetector', function (Server $c) { |
|
685 | + return new \OC\Files\Type\Detection( |
|
686 | + $c->getURLGenerator(), |
|
687 | + \OC::$configDir, |
|
688 | + \OC::$SERVERROOT . '/resources/config/' |
|
689 | + ); |
|
690 | + }); |
|
691 | + $this->registerService('MimeTypeLoader', function (Server $c) { |
|
692 | + return new \OC\Files\Type\Loader( |
|
693 | + $c->getDatabaseConnection() |
|
694 | + ); |
|
695 | + }); |
|
696 | + $this->registerService('NotificationManager', function (Server $c) { |
|
697 | + return new Manager( |
|
698 | + $c->query(IValidator::class) |
|
699 | + ); |
|
700 | + }); |
|
701 | + $this->registerService('CapabilitiesManager', function (Server $c) { |
|
702 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
703 | + $manager->registerCapability(function () use ($c) { |
|
704 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
705 | + }); |
|
706 | + return $manager; |
|
707 | + }); |
|
708 | + $this->registerService('CommentsManager', function(Server $c) { |
|
709 | + $config = $c->getConfig(); |
|
710 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
711 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
712 | + $factory = new $factoryClass($this); |
|
713 | + return $factory->getManager(); |
|
714 | + }); |
|
715 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
716 | + /* |
|
717 | 717 | * Dark magic for autoloader. |
718 | 718 | * If we do a class_exists it will try to load the class which will |
719 | 719 | * make composer cache the result. Resulting in errors when enabling |
720 | 720 | * the theming app. |
721 | 721 | */ |
722 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
723 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
724 | - $classExists = true; |
|
725 | - } else { |
|
726 | - $classExists = false; |
|
727 | - } |
|
728 | - |
|
729 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
730 | - return new ThemingDefaults( |
|
731 | - $c->getConfig(), |
|
732 | - $c->getL10N('theming'), |
|
733 | - $c->getURLGenerator(), |
|
734 | - new \OC_Defaults(), |
|
735 | - $c->getLazyRootFolder(), |
|
736 | - $c->getMemCacheFactory() |
|
737 | - ); |
|
738 | - } |
|
739 | - return new \OC_Defaults(); |
|
740 | - }); |
|
741 | - $this->registerService('EventDispatcher', function () { |
|
742 | - return new EventDispatcher(); |
|
743 | - }); |
|
744 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
745 | - // FIXME: Instantiiated here due to cyclic dependency |
|
746 | - $request = new Request( |
|
747 | - [ |
|
748 | - 'get' => $_GET, |
|
749 | - 'post' => $_POST, |
|
750 | - 'files' => $_FILES, |
|
751 | - 'server' => $_SERVER, |
|
752 | - 'env' => $_ENV, |
|
753 | - 'cookies' => $_COOKIE, |
|
754 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
755 | - ? $_SERVER['REQUEST_METHOD'] |
|
756 | - : null, |
|
757 | - ], |
|
758 | - $c->getSecureRandom(), |
|
759 | - $c->getConfig() |
|
760 | - ); |
|
761 | - |
|
762 | - return new CryptoWrapper( |
|
763 | - $c->getConfig(), |
|
764 | - $c->getCrypto(), |
|
765 | - $c->getSecureRandom(), |
|
766 | - $request |
|
767 | - ); |
|
768 | - }); |
|
769 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
770 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
771 | - |
|
772 | - return new CsrfTokenManager( |
|
773 | - $tokenGenerator, |
|
774 | - $c->query(SessionStorage::class) |
|
775 | - ); |
|
776 | - }); |
|
777 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
778 | - return new SessionStorage($c->getSession()); |
|
779 | - }); |
|
780 | - $this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
|
781 | - return new ContentSecurityPolicyManager(); |
|
782 | - }); |
|
783 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
784 | - return new ContentSecurityPolicyNonceManager( |
|
785 | - $c->getCsrfTokenManager(), |
|
786 | - $c->getRequest() |
|
787 | - ); |
|
788 | - }); |
|
789 | - $this->registerService('ShareManager', function(Server $c) { |
|
790 | - $config = $c->getConfig(); |
|
791 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
792 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
793 | - $factory = new $factoryClass($this); |
|
794 | - |
|
795 | - $manager = new \OC\Share20\Manager( |
|
796 | - $c->getLogger(), |
|
797 | - $c->getConfig(), |
|
798 | - $c->getSecureRandom(), |
|
799 | - $c->getHasher(), |
|
800 | - $c->getMountManager(), |
|
801 | - $c->getGroupManager(), |
|
802 | - $c->getL10N('core'), |
|
803 | - $factory, |
|
804 | - $c->getUserManager(), |
|
805 | - $c->getLazyRootFolder(), |
|
806 | - $c->getEventDispatcher() |
|
807 | - ); |
|
808 | - |
|
809 | - return $manager; |
|
810 | - }); |
|
811 | - $this->registerService('SettingsManager', function(Server $c) { |
|
812 | - $manager = new \OC\Settings\Manager( |
|
813 | - $c->getLogger(), |
|
814 | - $c->getDatabaseConnection(), |
|
815 | - $c->getL10N('lib'), |
|
816 | - $c->getConfig(), |
|
817 | - $c->getEncryptionManager(), |
|
818 | - $c->getUserManager(), |
|
819 | - $c->getLockingProvider(), |
|
820 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
821 | - $c->getURLGenerator() |
|
822 | - ); |
|
823 | - return $manager; |
|
824 | - }); |
|
825 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
826 | - return new \OC\Files\AppData\Factory( |
|
827 | - $c->getRootFolder(), |
|
828 | - $c->getSystemConfig() |
|
829 | - ); |
|
830 | - }); |
|
831 | - |
|
832 | - $this->registerService('LockdownManager', function (Server $c) { |
|
833 | - return new LockdownManager(); |
|
834 | - }); |
|
835 | - |
|
836 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
837 | - return new CloudIdManager(); |
|
838 | - }); |
|
839 | - |
|
840 | - /* To trick DI since we don't extend the DIContainer here */ |
|
841 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
842 | - return new CleanPreviewsBackgroundJob( |
|
843 | - $c->getRootFolder(), |
|
844 | - $c->getLogger(), |
|
845 | - $c->getJobList(), |
|
846 | - new TimeFactory() |
|
847 | - ); |
|
848 | - }); |
|
849 | - } |
|
850 | - |
|
851 | - /** |
|
852 | - * @return \OCP\Contacts\IManager |
|
853 | - */ |
|
854 | - public function getContactsManager() { |
|
855 | - return $this->query('ContactsManager'); |
|
856 | - } |
|
857 | - |
|
858 | - /** |
|
859 | - * @return \OC\Encryption\Manager |
|
860 | - */ |
|
861 | - public function getEncryptionManager() { |
|
862 | - return $this->query('EncryptionManager'); |
|
863 | - } |
|
864 | - |
|
865 | - /** |
|
866 | - * @return \OC\Encryption\File |
|
867 | - */ |
|
868 | - public function getEncryptionFilesHelper() { |
|
869 | - return $this->query('EncryptionFileHelper'); |
|
870 | - } |
|
871 | - |
|
872 | - /** |
|
873 | - * @return \OCP\Encryption\Keys\IStorage |
|
874 | - */ |
|
875 | - public function getEncryptionKeyStorage() { |
|
876 | - return $this->query('EncryptionKeyStorage'); |
|
877 | - } |
|
878 | - |
|
879 | - /** |
|
880 | - * The current request object holding all information about the request |
|
881 | - * currently being processed is returned from this method. |
|
882 | - * In case the current execution was not initiated by a web request null is returned |
|
883 | - * |
|
884 | - * @return \OCP\IRequest |
|
885 | - */ |
|
886 | - public function getRequest() { |
|
887 | - return $this->query('Request'); |
|
888 | - } |
|
889 | - |
|
890 | - /** |
|
891 | - * Returns the preview manager which can create preview images for a given file |
|
892 | - * |
|
893 | - * @return \OCP\IPreview |
|
894 | - */ |
|
895 | - public function getPreviewManager() { |
|
896 | - return $this->query('PreviewManager'); |
|
897 | - } |
|
898 | - |
|
899 | - /** |
|
900 | - * Returns the tag manager which can get and set tags for different object types |
|
901 | - * |
|
902 | - * @see \OCP\ITagManager::load() |
|
903 | - * @return \OCP\ITagManager |
|
904 | - */ |
|
905 | - public function getTagManager() { |
|
906 | - return $this->query('TagManager'); |
|
907 | - } |
|
908 | - |
|
909 | - /** |
|
910 | - * Returns the system-tag manager |
|
911 | - * |
|
912 | - * @return \OCP\SystemTag\ISystemTagManager |
|
913 | - * |
|
914 | - * @since 9.0.0 |
|
915 | - */ |
|
916 | - public function getSystemTagManager() { |
|
917 | - return $this->query('SystemTagManager'); |
|
918 | - } |
|
919 | - |
|
920 | - /** |
|
921 | - * Returns the system-tag object mapper |
|
922 | - * |
|
923 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
924 | - * |
|
925 | - * @since 9.0.0 |
|
926 | - */ |
|
927 | - public function getSystemTagObjectMapper() { |
|
928 | - return $this->query('SystemTagObjectMapper'); |
|
929 | - } |
|
930 | - |
|
931 | - /** |
|
932 | - * Returns the avatar manager, used for avatar functionality |
|
933 | - * |
|
934 | - * @return \OCP\IAvatarManager |
|
935 | - */ |
|
936 | - public function getAvatarManager() { |
|
937 | - return $this->query('AvatarManager'); |
|
938 | - } |
|
939 | - |
|
940 | - /** |
|
941 | - * Returns the root folder of ownCloud's data directory |
|
942 | - * |
|
943 | - * @return \OCP\Files\IRootFolder |
|
944 | - */ |
|
945 | - public function getRootFolder() { |
|
946 | - return $this->query('LazyRootFolder'); |
|
947 | - } |
|
948 | - |
|
949 | - /** |
|
950 | - * Returns the root folder of ownCloud's data directory |
|
951 | - * This is the lazy variant so this gets only initialized once it |
|
952 | - * is actually used. |
|
953 | - * |
|
954 | - * @return \OCP\Files\IRootFolder |
|
955 | - */ |
|
956 | - public function getLazyRootFolder() { |
|
957 | - return $this->query('LazyRootFolder'); |
|
958 | - } |
|
959 | - |
|
960 | - /** |
|
961 | - * Returns a view to ownCloud's files folder |
|
962 | - * |
|
963 | - * @param string $userId user ID |
|
964 | - * @return \OCP\Files\Folder|null |
|
965 | - */ |
|
966 | - public function getUserFolder($userId = null) { |
|
967 | - if ($userId === null) { |
|
968 | - $user = $this->getUserSession()->getUser(); |
|
969 | - if (!$user) { |
|
970 | - return null; |
|
971 | - } |
|
972 | - $userId = $user->getUID(); |
|
973 | - } |
|
974 | - $root = $this->getRootFolder(); |
|
975 | - return $root->getUserFolder($userId); |
|
976 | - } |
|
977 | - |
|
978 | - /** |
|
979 | - * Returns an app-specific view in ownClouds data directory |
|
980 | - * |
|
981 | - * @return \OCP\Files\Folder |
|
982 | - * @deprecated since 9.2.0 use IAppData |
|
983 | - */ |
|
984 | - public function getAppFolder() { |
|
985 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
986 | - $root = $this->getRootFolder(); |
|
987 | - if (!$root->nodeExists($dir)) { |
|
988 | - $folder = $root->newFolder($dir); |
|
989 | - } else { |
|
990 | - $folder = $root->get($dir); |
|
991 | - } |
|
992 | - return $folder; |
|
993 | - } |
|
994 | - |
|
995 | - /** |
|
996 | - * @return \OC\User\Manager |
|
997 | - */ |
|
998 | - public function getUserManager() { |
|
999 | - return $this->query('UserManager'); |
|
1000 | - } |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * @return \OC\Group\Manager |
|
1004 | - */ |
|
1005 | - public function getGroupManager() { |
|
1006 | - return $this->query('GroupManager'); |
|
1007 | - } |
|
1008 | - |
|
1009 | - /** |
|
1010 | - * @return \OC\User\Session |
|
1011 | - */ |
|
1012 | - public function getUserSession() { |
|
1013 | - return $this->query('UserSession'); |
|
1014 | - } |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * @return \OCP\ISession |
|
1018 | - */ |
|
1019 | - public function getSession() { |
|
1020 | - return $this->query('UserSession')->getSession(); |
|
1021 | - } |
|
1022 | - |
|
1023 | - /** |
|
1024 | - * @param \OCP\ISession $session |
|
1025 | - */ |
|
1026 | - public function setSession(\OCP\ISession $session) { |
|
1027 | - $this->query(SessionStorage::class)->setSession($session); |
|
1028 | - $this->query('UserSession')->setSession($session); |
|
1029 | - $this->query(Store::class)->setSession($session); |
|
1030 | - } |
|
1031 | - |
|
1032 | - /** |
|
1033 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1034 | - */ |
|
1035 | - public function getTwoFactorAuthManager() { |
|
1036 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1037 | - } |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * @return \OC\NavigationManager |
|
1041 | - */ |
|
1042 | - public function getNavigationManager() { |
|
1043 | - return $this->query('NavigationManager'); |
|
1044 | - } |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * @return \OCP\IConfig |
|
1048 | - */ |
|
1049 | - public function getConfig() { |
|
1050 | - return $this->query('AllConfig'); |
|
1051 | - } |
|
1052 | - |
|
1053 | - /** |
|
1054 | - * @internal For internal use only |
|
1055 | - * @return \OC\SystemConfig |
|
1056 | - */ |
|
1057 | - public function getSystemConfig() { |
|
1058 | - return $this->query('SystemConfig'); |
|
1059 | - } |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * Returns the app config manager |
|
1063 | - * |
|
1064 | - * @return \OCP\IAppConfig |
|
1065 | - */ |
|
1066 | - public function getAppConfig() { |
|
1067 | - return $this->query('AppConfig'); |
|
1068 | - } |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * @return \OCP\L10N\IFactory |
|
1072 | - */ |
|
1073 | - public function getL10NFactory() { |
|
1074 | - return $this->query('L10NFactory'); |
|
1075 | - } |
|
1076 | - |
|
1077 | - /** |
|
1078 | - * get an L10N instance |
|
1079 | - * |
|
1080 | - * @param string $app appid |
|
1081 | - * @param string $lang |
|
1082 | - * @return IL10N |
|
1083 | - */ |
|
1084 | - public function getL10N($app, $lang = null) { |
|
1085 | - return $this->getL10NFactory()->get($app, $lang); |
|
1086 | - } |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * @return \OCP\IURLGenerator |
|
1090 | - */ |
|
1091 | - public function getURLGenerator() { |
|
1092 | - return $this->query('URLGenerator'); |
|
1093 | - } |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * @return \OCP\IHelper |
|
1097 | - */ |
|
1098 | - public function getHelper() { |
|
1099 | - return $this->query('AppHelper'); |
|
1100 | - } |
|
1101 | - |
|
1102 | - /** |
|
1103 | - * @return AppFetcher |
|
1104 | - */ |
|
1105 | - public function getAppFetcher() { |
|
1106 | - return $this->query('AppFetcher'); |
|
1107 | - } |
|
1108 | - |
|
1109 | - /** |
|
1110 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1111 | - * getMemCacheFactory() instead. |
|
1112 | - * |
|
1113 | - * @return \OCP\ICache |
|
1114 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1115 | - */ |
|
1116 | - public function getCache() { |
|
1117 | - return $this->query('UserCache'); |
|
1118 | - } |
|
1119 | - |
|
1120 | - /** |
|
1121 | - * Returns an \OCP\CacheFactory instance |
|
1122 | - * |
|
1123 | - * @return \OCP\ICacheFactory |
|
1124 | - */ |
|
1125 | - public function getMemCacheFactory() { |
|
1126 | - return $this->query('MemCacheFactory'); |
|
1127 | - } |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * Returns an \OC\RedisFactory instance |
|
1131 | - * |
|
1132 | - * @return \OC\RedisFactory |
|
1133 | - */ |
|
1134 | - public function getGetRedisFactory() { |
|
1135 | - return $this->query('RedisFactory'); |
|
1136 | - } |
|
1137 | - |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * Returns the current session |
|
1141 | - * |
|
1142 | - * @return \OCP\IDBConnection |
|
1143 | - */ |
|
1144 | - public function getDatabaseConnection() { |
|
1145 | - return $this->query('DatabaseConnection'); |
|
1146 | - } |
|
1147 | - |
|
1148 | - /** |
|
1149 | - * Returns the activity manager |
|
1150 | - * |
|
1151 | - * @return \OCP\Activity\IManager |
|
1152 | - */ |
|
1153 | - public function getActivityManager() { |
|
1154 | - return $this->query('ActivityManager'); |
|
1155 | - } |
|
1156 | - |
|
1157 | - /** |
|
1158 | - * Returns an job list for controlling background jobs |
|
1159 | - * |
|
1160 | - * @return \OCP\BackgroundJob\IJobList |
|
1161 | - */ |
|
1162 | - public function getJobList() { |
|
1163 | - return $this->query('JobList'); |
|
1164 | - } |
|
1165 | - |
|
1166 | - /** |
|
1167 | - * Returns a logger instance |
|
1168 | - * |
|
1169 | - * @return \OCP\ILogger |
|
1170 | - */ |
|
1171 | - public function getLogger() { |
|
1172 | - return $this->query('Logger'); |
|
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * Returns a router for generating and matching urls |
|
1177 | - * |
|
1178 | - * @return \OCP\Route\IRouter |
|
1179 | - */ |
|
1180 | - public function getRouter() { |
|
1181 | - return $this->query('Router'); |
|
1182 | - } |
|
1183 | - |
|
1184 | - /** |
|
1185 | - * Returns a search instance |
|
1186 | - * |
|
1187 | - * @return \OCP\ISearch |
|
1188 | - */ |
|
1189 | - public function getSearch() { |
|
1190 | - return $this->query('Search'); |
|
1191 | - } |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * Returns a SecureRandom instance |
|
1195 | - * |
|
1196 | - * @return \OCP\Security\ISecureRandom |
|
1197 | - */ |
|
1198 | - public function getSecureRandom() { |
|
1199 | - return $this->query('SecureRandom'); |
|
1200 | - } |
|
1201 | - |
|
1202 | - /** |
|
1203 | - * Returns a Crypto instance |
|
1204 | - * |
|
1205 | - * @return \OCP\Security\ICrypto |
|
1206 | - */ |
|
1207 | - public function getCrypto() { |
|
1208 | - return $this->query('Crypto'); |
|
1209 | - } |
|
1210 | - |
|
1211 | - /** |
|
1212 | - * Returns a Hasher instance |
|
1213 | - * |
|
1214 | - * @return \OCP\Security\IHasher |
|
1215 | - */ |
|
1216 | - public function getHasher() { |
|
1217 | - return $this->query('Hasher'); |
|
1218 | - } |
|
1219 | - |
|
1220 | - /** |
|
1221 | - * Returns a CredentialsManager instance |
|
1222 | - * |
|
1223 | - * @return \OCP\Security\ICredentialsManager |
|
1224 | - */ |
|
1225 | - public function getCredentialsManager() { |
|
1226 | - return $this->query('CredentialsManager'); |
|
1227 | - } |
|
1228 | - |
|
1229 | - /** |
|
1230 | - * Returns an instance of the HTTP helper class |
|
1231 | - * |
|
1232 | - * @deprecated Use getHTTPClientService() |
|
1233 | - * @return \OC\HTTPHelper |
|
1234 | - */ |
|
1235 | - public function getHTTPHelper() { |
|
1236 | - return $this->query('HTTPHelper'); |
|
1237 | - } |
|
1238 | - |
|
1239 | - /** |
|
1240 | - * Get the certificate manager for the user |
|
1241 | - * |
|
1242 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1243 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1244 | - */ |
|
1245 | - public function getCertificateManager($userId = '') { |
|
1246 | - if ($userId === '') { |
|
1247 | - $userSession = $this->getUserSession(); |
|
1248 | - $user = $userSession->getUser(); |
|
1249 | - if (is_null($user)) { |
|
1250 | - return null; |
|
1251 | - } |
|
1252 | - $userId = $user->getUID(); |
|
1253 | - } |
|
1254 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1255 | - } |
|
1256 | - |
|
1257 | - /** |
|
1258 | - * Returns an instance of the HTTP client service |
|
1259 | - * |
|
1260 | - * @return \OCP\Http\Client\IClientService |
|
1261 | - */ |
|
1262 | - public function getHTTPClientService() { |
|
1263 | - return $this->query('HttpClientService'); |
|
1264 | - } |
|
1265 | - |
|
1266 | - /** |
|
1267 | - * Create a new event source |
|
1268 | - * |
|
1269 | - * @return \OCP\IEventSource |
|
1270 | - */ |
|
1271 | - public function createEventSource() { |
|
1272 | - return new \OC_EventSource(); |
|
1273 | - } |
|
1274 | - |
|
1275 | - /** |
|
1276 | - * Get the active event logger |
|
1277 | - * |
|
1278 | - * The returned logger only logs data when debug mode is enabled |
|
1279 | - * |
|
1280 | - * @return \OCP\Diagnostics\IEventLogger |
|
1281 | - */ |
|
1282 | - public function getEventLogger() { |
|
1283 | - return $this->query('EventLogger'); |
|
1284 | - } |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * Get the active query logger |
|
1288 | - * |
|
1289 | - * The returned logger only logs data when debug mode is enabled |
|
1290 | - * |
|
1291 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1292 | - */ |
|
1293 | - public function getQueryLogger() { |
|
1294 | - return $this->query('QueryLogger'); |
|
1295 | - } |
|
1296 | - |
|
1297 | - /** |
|
1298 | - * Get the manager for temporary files and folders |
|
1299 | - * |
|
1300 | - * @return \OCP\ITempManager |
|
1301 | - */ |
|
1302 | - public function getTempManager() { |
|
1303 | - return $this->query('TempManager'); |
|
1304 | - } |
|
1305 | - |
|
1306 | - /** |
|
1307 | - * Get the app manager |
|
1308 | - * |
|
1309 | - * @return \OCP\App\IAppManager |
|
1310 | - */ |
|
1311 | - public function getAppManager() { |
|
1312 | - return $this->query('AppManager'); |
|
1313 | - } |
|
1314 | - |
|
1315 | - /** |
|
1316 | - * Creates a new mailer |
|
1317 | - * |
|
1318 | - * @return \OCP\Mail\IMailer |
|
1319 | - */ |
|
1320 | - public function getMailer() { |
|
1321 | - return $this->query('Mailer'); |
|
1322 | - } |
|
1323 | - |
|
1324 | - /** |
|
1325 | - * Get the webroot |
|
1326 | - * |
|
1327 | - * @return string |
|
1328 | - */ |
|
1329 | - public function getWebRoot() { |
|
1330 | - return $this->webRoot; |
|
1331 | - } |
|
1332 | - |
|
1333 | - /** |
|
1334 | - * @return \OC\OCSClient |
|
1335 | - */ |
|
1336 | - public function getOcsClient() { |
|
1337 | - return $this->query('OcsClient'); |
|
1338 | - } |
|
1339 | - |
|
1340 | - /** |
|
1341 | - * @return \OCP\IDateTimeZone |
|
1342 | - */ |
|
1343 | - public function getDateTimeZone() { |
|
1344 | - return $this->query('DateTimeZone'); |
|
1345 | - } |
|
1346 | - |
|
1347 | - /** |
|
1348 | - * @return \OCP\IDateTimeFormatter |
|
1349 | - */ |
|
1350 | - public function getDateTimeFormatter() { |
|
1351 | - return $this->query('DateTimeFormatter'); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1356 | - */ |
|
1357 | - public function getMountProviderCollection() { |
|
1358 | - return $this->query('MountConfigManager'); |
|
1359 | - } |
|
1360 | - |
|
1361 | - /** |
|
1362 | - * Get the IniWrapper |
|
1363 | - * |
|
1364 | - * @return IniGetWrapper |
|
1365 | - */ |
|
1366 | - public function getIniWrapper() { |
|
1367 | - return $this->query('IniWrapper'); |
|
1368 | - } |
|
1369 | - |
|
1370 | - /** |
|
1371 | - * @return \OCP\Command\IBus |
|
1372 | - */ |
|
1373 | - public function getCommandBus() { |
|
1374 | - return $this->query('AsyncCommandBus'); |
|
1375 | - } |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * Get the trusted domain helper |
|
1379 | - * |
|
1380 | - * @return TrustedDomainHelper |
|
1381 | - */ |
|
1382 | - public function getTrustedDomainHelper() { |
|
1383 | - return $this->query('TrustedDomainHelper'); |
|
1384 | - } |
|
1385 | - |
|
1386 | - /** |
|
1387 | - * Get the locking provider |
|
1388 | - * |
|
1389 | - * @return \OCP\Lock\ILockingProvider |
|
1390 | - * @since 8.1.0 |
|
1391 | - */ |
|
1392 | - public function getLockingProvider() { |
|
1393 | - return $this->query('LockingProvider'); |
|
1394 | - } |
|
1395 | - |
|
1396 | - /** |
|
1397 | - * @return \OCP\Files\Mount\IMountManager |
|
1398 | - **/ |
|
1399 | - function getMountManager() { |
|
1400 | - return $this->query('MountManager'); |
|
1401 | - } |
|
1402 | - |
|
1403 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1404 | - function getUserMountCache() { |
|
1405 | - return $this->query('UserMountCache'); |
|
1406 | - } |
|
1407 | - |
|
1408 | - /** |
|
1409 | - * Get the MimeTypeDetector |
|
1410 | - * |
|
1411 | - * @return \OCP\Files\IMimeTypeDetector |
|
1412 | - */ |
|
1413 | - public function getMimeTypeDetector() { |
|
1414 | - return $this->query('MimeTypeDetector'); |
|
1415 | - } |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * Get the MimeTypeLoader |
|
1419 | - * |
|
1420 | - * @return \OCP\Files\IMimeTypeLoader |
|
1421 | - */ |
|
1422 | - public function getMimeTypeLoader() { |
|
1423 | - return $this->query('MimeTypeLoader'); |
|
1424 | - } |
|
1425 | - |
|
1426 | - /** |
|
1427 | - * Get the manager of all the capabilities |
|
1428 | - * |
|
1429 | - * @return \OC\CapabilitiesManager |
|
1430 | - */ |
|
1431 | - public function getCapabilitiesManager() { |
|
1432 | - return $this->query('CapabilitiesManager'); |
|
1433 | - } |
|
1434 | - |
|
1435 | - /** |
|
1436 | - * Get the EventDispatcher |
|
1437 | - * |
|
1438 | - * @return EventDispatcherInterface |
|
1439 | - * @since 8.2.0 |
|
1440 | - */ |
|
1441 | - public function getEventDispatcher() { |
|
1442 | - return $this->query('EventDispatcher'); |
|
1443 | - } |
|
1444 | - |
|
1445 | - /** |
|
1446 | - * Get the Notification Manager |
|
1447 | - * |
|
1448 | - * @return \OCP\Notification\IManager |
|
1449 | - * @since 8.2.0 |
|
1450 | - */ |
|
1451 | - public function getNotificationManager() { |
|
1452 | - return $this->query('NotificationManager'); |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * @return \OCP\Comments\ICommentsManager |
|
1457 | - */ |
|
1458 | - public function getCommentsManager() { |
|
1459 | - return $this->query('CommentsManager'); |
|
1460 | - } |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * @return \OC_Defaults |
|
1464 | - */ |
|
1465 | - public function getThemingDefaults() { |
|
1466 | - return $this->query('ThemingDefaults'); |
|
1467 | - } |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * @return \OC\IntegrityCheck\Checker |
|
1471 | - */ |
|
1472 | - public function getIntegrityCodeChecker() { |
|
1473 | - return $this->query('IntegrityCodeChecker'); |
|
1474 | - } |
|
1475 | - |
|
1476 | - /** |
|
1477 | - * @return \OC\Session\CryptoWrapper |
|
1478 | - */ |
|
1479 | - public function getSessionCryptoWrapper() { |
|
1480 | - return $this->query('CryptoWrapper'); |
|
1481 | - } |
|
1482 | - |
|
1483 | - /** |
|
1484 | - * @return CsrfTokenManager |
|
1485 | - */ |
|
1486 | - public function getCsrfTokenManager() { |
|
1487 | - return $this->query('CsrfTokenManager'); |
|
1488 | - } |
|
1489 | - |
|
1490 | - /** |
|
1491 | - * @return Throttler |
|
1492 | - */ |
|
1493 | - public function getBruteForceThrottler() { |
|
1494 | - return $this->query('Throttler'); |
|
1495 | - } |
|
1496 | - |
|
1497 | - /** |
|
1498 | - * @return IContentSecurityPolicyManager |
|
1499 | - */ |
|
1500 | - public function getContentSecurityPolicyManager() { |
|
1501 | - return $this->query('ContentSecurityPolicyManager'); |
|
1502 | - } |
|
1503 | - |
|
1504 | - /** |
|
1505 | - * @return ContentSecurityPolicyNonceManager |
|
1506 | - */ |
|
1507 | - public function getContentSecurityPolicyNonceManager() { |
|
1508 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1509 | - } |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * Not a public API as of 8.2, wait for 9.0 |
|
1513 | - * |
|
1514 | - * @return \OCA\Files_External\Service\BackendService |
|
1515 | - */ |
|
1516 | - public function getStoragesBackendService() { |
|
1517 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1518 | - } |
|
1519 | - |
|
1520 | - /** |
|
1521 | - * Not a public API as of 8.2, wait for 9.0 |
|
1522 | - * |
|
1523 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1524 | - */ |
|
1525 | - public function getGlobalStoragesService() { |
|
1526 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1527 | - } |
|
1528 | - |
|
1529 | - /** |
|
1530 | - * Not a public API as of 8.2, wait for 9.0 |
|
1531 | - * |
|
1532 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1533 | - */ |
|
1534 | - public function getUserGlobalStoragesService() { |
|
1535 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1536 | - } |
|
1537 | - |
|
1538 | - /** |
|
1539 | - * Not a public API as of 8.2, wait for 9.0 |
|
1540 | - * |
|
1541 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1542 | - */ |
|
1543 | - public function getUserStoragesService() { |
|
1544 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1545 | - } |
|
1546 | - |
|
1547 | - /** |
|
1548 | - * @return \OCP\Share\IManager |
|
1549 | - */ |
|
1550 | - public function getShareManager() { |
|
1551 | - return $this->query('ShareManager'); |
|
1552 | - } |
|
1553 | - |
|
1554 | - /** |
|
1555 | - * Returns the LDAP Provider |
|
1556 | - * |
|
1557 | - * @return \OCP\LDAP\ILDAPProvider |
|
1558 | - */ |
|
1559 | - public function getLDAPProvider() { |
|
1560 | - return $this->query('LDAPProvider'); |
|
1561 | - } |
|
1562 | - |
|
1563 | - /** |
|
1564 | - * @return \OCP\Settings\IManager |
|
1565 | - */ |
|
1566 | - public function getSettingsManager() { |
|
1567 | - return $this->query('SettingsManager'); |
|
1568 | - } |
|
1569 | - |
|
1570 | - /** |
|
1571 | - * @return \OCP\Files\IAppData |
|
1572 | - */ |
|
1573 | - public function getAppDataDir($app) { |
|
1574 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1575 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1576 | - return $factory->get($app); |
|
1577 | - } |
|
1578 | - |
|
1579 | - /** |
|
1580 | - * @return \OCP\Lockdown\ILockdownManager |
|
1581 | - */ |
|
1582 | - public function getLockdownManager() { |
|
1583 | - return $this->query('LockdownManager'); |
|
1584 | - } |
|
1585 | - |
|
1586 | - /** |
|
1587 | - * @return \OCP\Federation\ICloudIdManager |
|
1588 | - */ |
|
1589 | - public function getCloudIdManager() { |
|
1590 | - return $this->query(ICloudIdManager::class); |
|
1591 | - } |
|
722 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
723 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
724 | + $classExists = true; |
|
725 | + } else { |
|
726 | + $classExists = false; |
|
727 | + } |
|
728 | + |
|
729 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
730 | + return new ThemingDefaults( |
|
731 | + $c->getConfig(), |
|
732 | + $c->getL10N('theming'), |
|
733 | + $c->getURLGenerator(), |
|
734 | + new \OC_Defaults(), |
|
735 | + $c->getLazyRootFolder(), |
|
736 | + $c->getMemCacheFactory() |
|
737 | + ); |
|
738 | + } |
|
739 | + return new \OC_Defaults(); |
|
740 | + }); |
|
741 | + $this->registerService('EventDispatcher', function () { |
|
742 | + return new EventDispatcher(); |
|
743 | + }); |
|
744 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
745 | + // FIXME: Instantiiated here due to cyclic dependency |
|
746 | + $request = new Request( |
|
747 | + [ |
|
748 | + 'get' => $_GET, |
|
749 | + 'post' => $_POST, |
|
750 | + 'files' => $_FILES, |
|
751 | + 'server' => $_SERVER, |
|
752 | + 'env' => $_ENV, |
|
753 | + 'cookies' => $_COOKIE, |
|
754 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
755 | + ? $_SERVER['REQUEST_METHOD'] |
|
756 | + : null, |
|
757 | + ], |
|
758 | + $c->getSecureRandom(), |
|
759 | + $c->getConfig() |
|
760 | + ); |
|
761 | + |
|
762 | + return new CryptoWrapper( |
|
763 | + $c->getConfig(), |
|
764 | + $c->getCrypto(), |
|
765 | + $c->getSecureRandom(), |
|
766 | + $request |
|
767 | + ); |
|
768 | + }); |
|
769 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
770 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
771 | + |
|
772 | + return new CsrfTokenManager( |
|
773 | + $tokenGenerator, |
|
774 | + $c->query(SessionStorage::class) |
|
775 | + ); |
|
776 | + }); |
|
777 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
778 | + return new SessionStorage($c->getSession()); |
|
779 | + }); |
|
780 | + $this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
|
781 | + return new ContentSecurityPolicyManager(); |
|
782 | + }); |
|
783 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
784 | + return new ContentSecurityPolicyNonceManager( |
|
785 | + $c->getCsrfTokenManager(), |
|
786 | + $c->getRequest() |
|
787 | + ); |
|
788 | + }); |
|
789 | + $this->registerService('ShareManager', function(Server $c) { |
|
790 | + $config = $c->getConfig(); |
|
791 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
792 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
793 | + $factory = new $factoryClass($this); |
|
794 | + |
|
795 | + $manager = new \OC\Share20\Manager( |
|
796 | + $c->getLogger(), |
|
797 | + $c->getConfig(), |
|
798 | + $c->getSecureRandom(), |
|
799 | + $c->getHasher(), |
|
800 | + $c->getMountManager(), |
|
801 | + $c->getGroupManager(), |
|
802 | + $c->getL10N('core'), |
|
803 | + $factory, |
|
804 | + $c->getUserManager(), |
|
805 | + $c->getLazyRootFolder(), |
|
806 | + $c->getEventDispatcher() |
|
807 | + ); |
|
808 | + |
|
809 | + return $manager; |
|
810 | + }); |
|
811 | + $this->registerService('SettingsManager', function(Server $c) { |
|
812 | + $manager = new \OC\Settings\Manager( |
|
813 | + $c->getLogger(), |
|
814 | + $c->getDatabaseConnection(), |
|
815 | + $c->getL10N('lib'), |
|
816 | + $c->getConfig(), |
|
817 | + $c->getEncryptionManager(), |
|
818 | + $c->getUserManager(), |
|
819 | + $c->getLockingProvider(), |
|
820 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
821 | + $c->getURLGenerator() |
|
822 | + ); |
|
823 | + return $manager; |
|
824 | + }); |
|
825 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
826 | + return new \OC\Files\AppData\Factory( |
|
827 | + $c->getRootFolder(), |
|
828 | + $c->getSystemConfig() |
|
829 | + ); |
|
830 | + }); |
|
831 | + |
|
832 | + $this->registerService('LockdownManager', function (Server $c) { |
|
833 | + return new LockdownManager(); |
|
834 | + }); |
|
835 | + |
|
836 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
837 | + return new CloudIdManager(); |
|
838 | + }); |
|
839 | + |
|
840 | + /* To trick DI since we don't extend the DIContainer here */ |
|
841 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
842 | + return new CleanPreviewsBackgroundJob( |
|
843 | + $c->getRootFolder(), |
|
844 | + $c->getLogger(), |
|
845 | + $c->getJobList(), |
|
846 | + new TimeFactory() |
|
847 | + ); |
|
848 | + }); |
|
849 | + } |
|
850 | + |
|
851 | + /** |
|
852 | + * @return \OCP\Contacts\IManager |
|
853 | + */ |
|
854 | + public function getContactsManager() { |
|
855 | + return $this->query('ContactsManager'); |
|
856 | + } |
|
857 | + |
|
858 | + /** |
|
859 | + * @return \OC\Encryption\Manager |
|
860 | + */ |
|
861 | + public function getEncryptionManager() { |
|
862 | + return $this->query('EncryptionManager'); |
|
863 | + } |
|
864 | + |
|
865 | + /** |
|
866 | + * @return \OC\Encryption\File |
|
867 | + */ |
|
868 | + public function getEncryptionFilesHelper() { |
|
869 | + return $this->query('EncryptionFileHelper'); |
|
870 | + } |
|
871 | + |
|
872 | + /** |
|
873 | + * @return \OCP\Encryption\Keys\IStorage |
|
874 | + */ |
|
875 | + public function getEncryptionKeyStorage() { |
|
876 | + return $this->query('EncryptionKeyStorage'); |
|
877 | + } |
|
878 | + |
|
879 | + /** |
|
880 | + * The current request object holding all information about the request |
|
881 | + * currently being processed is returned from this method. |
|
882 | + * In case the current execution was not initiated by a web request null is returned |
|
883 | + * |
|
884 | + * @return \OCP\IRequest |
|
885 | + */ |
|
886 | + public function getRequest() { |
|
887 | + return $this->query('Request'); |
|
888 | + } |
|
889 | + |
|
890 | + /** |
|
891 | + * Returns the preview manager which can create preview images for a given file |
|
892 | + * |
|
893 | + * @return \OCP\IPreview |
|
894 | + */ |
|
895 | + public function getPreviewManager() { |
|
896 | + return $this->query('PreviewManager'); |
|
897 | + } |
|
898 | + |
|
899 | + /** |
|
900 | + * Returns the tag manager which can get and set tags for different object types |
|
901 | + * |
|
902 | + * @see \OCP\ITagManager::load() |
|
903 | + * @return \OCP\ITagManager |
|
904 | + */ |
|
905 | + public function getTagManager() { |
|
906 | + return $this->query('TagManager'); |
|
907 | + } |
|
908 | + |
|
909 | + /** |
|
910 | + * Returns the system-tag manager |
|
911 | + * |
|
912 | + * @return \OCP\SystemTag\ISystemTagManager |
|
913 | + * |
|
914 | + * @since 9.0.0 |
|
915 | + */ |
|
916 | + public function getSystemTagManager() { |
|
917 | + return $this->query('SystemTagManager'); |
|
918 | + } |
|
919 | + |
|
920 | + /** |
|
921 | + * Returns the system-tag object mapper |
|
922 | + * |
|
923 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
924 | + * |
|
925 | + * @since 9.0.0 |
|
926 | + */ |
|
927 | + public function getSystemTagObjectMapper() { |
|
928 | + return $this->query('SystemTagObjectMapper'); |
|
929 | + } |
|
930 | + |
|
931 | + /** |
|
932 | + * Returns the avatar manager, used for avatar functionality |
|
933 | + * |
|
934 | + * @return \OCP\IAvatarManager |
|
935 | + */ |
|
936 | + public function getAvatarManager() { |
|
937 | + return $this->query('AvatarManager'); |
|
938 | + } |
|
939 | + |
|
940 | + /** |
|
941 | + * Returns the root folder of ownCloud's data directory |
|
942 | + * |
|
943 | + * @return \OCP\Files\IRootFolder |
|
944 | + */ |
|
945 | + public function getRootFolder() { |
|
946 | + return $this->query('LazyRootFolder'); |
|
947 | + } |
|
948 | + |
|
949 | + /** |
|
950 | + * Returns the root folder of ownCloud's data directory |
|
951 | + * This is the lazy variant so this gets only initialized once it |
|
952 | + * is actually used. |
|
953 | + * |
|
954 | + * @return \OCP\Files\IRootFolder |
|
955 | + */ |
|
956 | + public function getLazyRootFolder() { |
|
957 | + return $this->query('LazyRootFolder'); |
|
958 | + } |
|
959 | + |
|
960 | + /** |
|
961 | + * Returns a view to ownCloud's files folder |
|
962 | + * |
|
963 | + * @param string $userId user ID |
|
964 | + * @return \OCP\Files\Folder|null |
|
965 | + */ |
|
966 | + public function getUserFolder($userId = null) { |
|
967 | + if ($userId === null) { |
|
968 | + $user = $this->getUserSession()->getUser(); |
|
969 | + if (!$user) { |
|
970 | + return null; |
|
971 | + } |
|
972 | + $userId = $user->getUID(); |
|
973 | + } |
|
974 | + $root = $this->getRootFolder(); |
|
975 | + return $root->getUserFolder($userId); |
|
976 | + } |
|
977 | + |
|
978 | + /** |
|
979 | + * Returns an app-specific view in ownClouds data directory |
|
980 | + * |
|
981 | + * @return \OCP\Files\Folder |
|
982 | + * @deprecated since 9.2.0 use IAppData |
|
983 | + */ |
|
984 | + public function getAppFolder() { |
|
985 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
986 | + $root = $this->getRootFolder(); |
|
987 | + if (!$root->nodeExists($dir)) { |
|
988 | + $folder = $root->newFolder($dir); |
|
989 | + } else { |
|
990 | + $folder = $root->get($dir); |
|
991 | + } |
|
992 | + return $folder; |
|
993 | + } |
|
994 | + |
|
995 | + /** |
|
996 | + * @return \OC\User\Manager |
|
997 | + */ |
|
998 | + public function getUserManager() { |
|
999 | + return $this->query('UserManager'); |
|
1000 | + } |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * @return \OC\Group\Manager |
|
1004 | + */ |
|
1005 | + public function getGroupManager() { |
|
1006 | + return $this->query('GroupManager'); |
|
1007 | + } |
|
1008 | + |
|
1009 | + /** |
|
1010 | + * @return \OC\User\Session |
|
1011 | + */ |
|
1012 | + public function getUserSession() { |
|
1013 | + return $this->query('UserSession'); |
|
1014 | + } |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * @return \OCP\ISession |
|
1018 | + */ |
|
1019 | + public function getSession() { |
|
1020 | + return $this->query('UserSession')->getSession(); |
|
1021 | + } |
|
1022 | + |
|
1023 | + /** |
|
1024 | + * @param \OCP\ISession $session |
|
1025 | + */ |
|
1026 | + public function setSession(\OCP\ISession $session) { |
|
1027 | + $this->query(SessionStorage::class)->setSession($session); |
|
1028 | + $this->query('UserSession')->setSession($session); |
|
1029 | + $this->query(Store::class)->setSession($session); |
|
1030 | + } |
|
1031 | + |
|
1032 | + /** |
|
1033 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1034 | + */ |
|
1035 | + public function getTwoFactorAuthManager() { |
|
1036 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1037 | + } |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * @return \OC\NavigationManager |
|
1041 | + */ |
|
1042 | + public function getNavigationManager() { |
|
1043 | + return $this->query('NavigationManager'); |
|
1044 | + } |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * @return \OCP\IConfig |
|
1048 | + */ |
|
1049 | + public function getConfig() { |
|
1050 | + return $this->query('AllConfig'); |
|
1051 | + } |
|
1052 | + |
|
1053 | + /** |
|
1054 | + * @internal For internal use only |
|
1055 | + * @return \OC\SystemConfig |
|
1056 | + */ |
|
1057 | + public function getSystemConfig() { |
|
1058 | + return $this->query('SystemConfig'); |
|
1059 | + } |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * Returns the app config manager |
|
1063 | + * |
|
1064 | + * @return \OCP\IAppConfig |
|
1065 | + */ |
|
1066 | + public function getAppConfig() { |
|
1067 | + return $this->query('AppConfig'); |
|
1068 | + } |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * @return \OCP\L10N\IFactory |
|
1072 | + */ |
|
1073 | + public function getL10NFactory() { |
|
1074 | + return $this->query('L10NFactory'); |
|
1075 | + } |
|
1076 | + |
|
1077 | + /** |
|
1078 | + * get an L10N instance |
|
1079 | + * |
|
1080 | + * @param string $app appid |
|
1081 | + * @param string $lang |
|
1082 | + * @return IL10N |
|
1083 | + */ |
|
1084 | + public function getL10N($app, $lang = null) { |
|
1085 | + return $this->getL10NFactory()->get($app, $lang); |
|
1086 | + } |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * @return \OCP\IURLGenerator |
|
1090 | + */ |
|
1091 | + public function getURLGenerator() { |
|
1092 | + return $this->query('URLGenerator'); |
|
1093 | + } |
|
1094 | + |
|
1095 | + /** |
|
1096 | + * @return \OCP\IHelper |
|
1097 | + */ |
|
1098 | + public function getHelper() { |
|
1099 | + return $this->query('AppHelper'); |
|
1100 | + } |
|
1101 | + |
|
1102 | + /** |
|
1103 | + * @return AppFetcher |
|
1104 | + */ |
|
1105 | + public function getAppFetcher() { |
|
1106 | + return $this->query('AppFetcher'); |
|
1107 | + } |
|
1108 | + |
|
1109 | + /** |
|
1110 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1111 | + * getMemCacheFactory() instead. |
|
1112 | + * |
|
1113 | + * @return \OCP\ICache |
|
1114 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1115 | + */ |
|
1116 | + public function getCache() { |
|
1117 | + return $this->query('UserCache'); |
|
1118 | + } |
|
1119 | + |
|
1120 | + /** |
|
1121 | + * Returns an \OCP\CacheFactory instance |
|
1122 | + * |
|
1123 | + * @return \OCP\ICacheFactory |
|
1124 | + */ |
|
1125 | + public function getMemCacheFactory() { |
|
1126 | + return $this->query('MemCacheFactory'); |
|
1127 | + } |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * Returns an \OC\RedisFactory instance |
|
1131 | + * |
|
1132 | + * @return \OC\RedisFactory |
|
1133 | + */ |
|
1134 | + public function getGetRedisFactory() { |
|
1135 | + return $this->query('RedisFactory'); |
|
1136 | + } |
|
1137 | + |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * Returns the current session |
|
1141 | + * |
|
1142 | + * @return \OCP\IDBConnection |
|
1143 | + */ |
|
1144 | + public function getDatabaseConnection() { |
|
1145 | + return $this->query('DatabaseConnection'); |
|
1146 | + } |
|
1147 | + |
|
1148 | + /** |
|
1149 | + * Returns the activity manager |
|
1150 | + * |
|
1151 | + * @return \OCP\Activity\IManager |
|
1152 | + */ |
|
1153 | + public function getActivityManager() { |
|
1154 | + return $this->query('ActivityManager'); |
|
1155 | + } |
|
1156 | + |
|
1157 | + /** |
|
1158 | + * Returns an job list for controlling background jobs |
|
1159 | + * |
|
1160 | + * @return \OCP\BackgroundJob\IJobList |
|
1161 | + */ |
|
1162 | + public function getJobList() { |
|
1163 | + return $this->query('JobList'); |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * Returns a logger instance |
|
1168 | + * |
|
1169 | + * @return \OCP\ILogger |
|
1170 | + */ |
|
1171 | + public function getLogger() { |
|
1172 | + return $this->query('Logger'); |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * Returns a router for generating and matching urls |
|
1177 | + * |
|
1178 | + * @return \OCP\Route\IRouter |
|
1179 | + */ |
|
1180 | + public function getRouter() { |
|
1181 | + return $this->query('Router'); |
|
1182 | + } |
|
1183 | + |
|
1184 | + /** |
|
1185 | + * Returns a search instance |
|
1186 | + * |
|
1187 | + * @return \OCP\ISearch |
|
1188 | + */ |
|
1189 | + public function getSearch() { |
|
1190 | + return $this->query('Search'); |
|
1191 | + } |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * Returns a SecureRandom instance |
|
1195 | + * |
|
1196 | + * @return \OCP\Security\ISecureRandom |
|
1197 | + */ |
|
1198 | + public function getSecureRandom() { |
|
1199 | + return $this->query('SecureRandom'); |
|
1200 | + } |
|
1201 | + |
|
1202 | + /** |
|
1203 | + * Returns a Crypto instance |
|
1204 | + * |
|
1205 | + * @return \OCP\Security\ICrypto |
|
1206 | + */ |
|
1207 | + public function getCrypto() { |
|
1208 | + return $this->query('Crypto'); |
|
1209 | + } |
|
1210 | + |
|
1211 | + /** |
|
1212 | + * Returns a Hasher instance |
|
1213 | + * |
|
1214 | + * @return \OCP\Security\IHasher |
|
1215 | + */ |
|
1216 | + public function getHasher() { |
|
1217 | + return $this->query('Hasher'); |
|
1218 | + } |
|
1219 | + |
|
1220 | + /** |
|
1221 | + * Returns a CredentialsManager instance |
|
1222 | + * |
|
1223 | + * @return \OCP\Security\ICredentialsManager |
|
1224 | + */ |
|
1225 | + public function getCredentialsManager() { |
|
1226 | + return $this->query('CredentialsManager'); |
|
1227 | + } |
|
1228 | + |
|
1229 | + /** |
|
1230 | + * Returns an instance of the HTTP helper class |
|
1231 | + * |
|
1232 | + * @deprecated Use getHTTPClientService() |
|
1233 | + * @return \OC\HTTPHelper |
|
1234 | + */ |
|
1235 | + public function getHTTPHelper() { |
|
1236 | + return $this->query('HTTPHelper'); |
|
1237 | + } |
|
1238 | + |
|
1239 | + /** |
|
1240 | + * Get the certificate manager for the user |
|
1241 | + * |
|
1242 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1243 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1244 | + */ |
|
1245 | + public function getCertificateManager($userId = '') { |
|
1246 | + if ($userId === '') { |
|
1247 | + $userSession = $this->getUserSession(); |
|
1248 | + $user = $userSession->getUser(); |
|
1249 | + if (is_null($user)) { |
|
1250 | + return null; |
|
1251 | + } |
|
1252 | + $userId = $user->getUID(); |
|
1253 | + } |
|
1254 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1255 | + } |
|
1256 | + |
|
1257 | + /** |
|
1258 | + * Returns an instance of the HTTP client service |
|
1259 | + * |
|
1260 | + * @return \OCP\Http\Client\IClientService |
|
1261 | + */ |
|
1262 | + public function getHTTPClientService() { |
|
1263 | + return $this->query('HttpClientService'); |
|
1264 | + } |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * Create a new event source |
|
1268 | + * |
|
1269 | + * @return \OCP\IEventSource |
|
1270 | + */ |
|
1271 | + public function createEventSource() { |
|
1272 | + return new \OC_EventSource(); |
|
1273 | + } |
|
1274 | + |
|
1275 | + /** |
|
1276 | + * Get the active event logger |
|
1277 | + * |
|
1278 | + * The returned logger only logs data when debug mode is enabled |
|
1279 | + * |
|
1280 | + * @return \OCP\Diagnostics\IEventLogger |
|
1281 | + */ |
|
1282 | + public function getEventLogger() { |
|
1283 | + return $this->query('EventLogger'); |
|
1284 | + } |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * Get the active query logger |
|
1288 | + * |
|
1289 | + * The returned logger only logs data when debug mode is enabled |
|
1290 | + * |
|
1291 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1292 | + */ |
|
1293 | + public function getQueryLogger() { |
|
1294 | + return $this->query('QueryLogger'); |
|
1295 | + } |
|
1296 | + |
|
1297 | + /** |
|
1298 | + * Get the manager for temporary files and folders |
|
1299 | + * |
|
1300 | + * @return \OCP\ITempManager |
|
1301 | + */ |
|
1302 | + public function getTempManager() { |
|
1303 | + return $this->query('TempManager'); |
|
1304 | + } |
|
1305 | + |
|
1306 | + /** |
|
1307 | + * Get the app manager |
|
1308 | + * |
|
1309 | + * @return \OCP\App\IAppManager |
|
1310 | + */ |
|
1311 | + public function getAppManager() { |
|
1312 | + return $this->query('AppManager'); |
|
1313 | + } |
|
1314 | + |
|
1315 | + /** |
|
1316 | + * Creates a new mailer |
|
1317 | + * |
|
1318 | + * @return \OCP\Mail\IMailer |
|
1319 | + */ |
|
1320 | + public function getMailer() { |
|
1321 | + return $this->query('Mailer'); |
|
1322 | + } |
|
1323 | + |
|
1324 | + /** |
|
1325 | + * Get the webroot |
|
1326 | + * |
|
1327 | + * @return string |
|
1328 | + */ |
|
1329 | + public function getWebRoot() { |
|
1330 | + return $this->webRoot; |
|
1331 | + } |
|
1332 | + |
|
1333 | + /** |
|
1334 | + * @return \OC\OCSClient |
|
1335 | + */ |
|
1336 | + public function getOcsClient() { |
|
1337 | + return $this->query('OcsClient'); |
|
1338 | + } |
|
1339 | + |
|
1340 | + /** |
|
1341 | + * @return \OCP\IDateTimeZone |
|
1342 | + */ |
|
1343 | + public function getDateTimeZone() { |
|
1344 | + return $this->query('DateTimeZone'); |
|
1345 | + } |
|
1346 | + |
|
1347 | + /** |
|
1348 | + * @return \OCP\IDateTimeFormatter |
|
1349 | + */ |
|
1350 | + public function getDateTimeFormatter() { |
|
1351 | + return $this->query('DateTimeFormatter'); |
|
1352 | + } |
|
1353 | + |
|
1354 | + /** |
|
1355 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1356 | + */ |
|
1357 | + public function getMountProviderCollection() { |
|
1358 | + return $this->query('MountConfigManager'); |
|
1359 | + } |
|
1360 | + |
|
1361 | + /** |
|
1362 | + * Get the IniWrapper |
|
1363 | + * |
|
1364 | + * @return IniGetWrapper |
|
1365 | + */ |
|
1366 | + public function getIniWrapper() { |
|
1367 | + return $this->query('IniWrapper'); |
|
1368 | + } |
|
1369 | + |
|
1370 | + /** |
|
1371 | + * @return \OCP\Command\IBus |
|
1372 | + */ |
|
1373 | + public function getCommandBus() { |
|
1374 | + return $this->query('AsyncCommandBus'); |
|
1375 | + } |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * Get the trusted domain helper |
|
1379 | + * |
|
1380 | + * @return TrustedDomainHelper |
|
1381 | + */ |
|
1382 | + public function getTrustedDomainHelper() { |
|
1383 | + return $this->query('TrustedDomainHelper'); |
|
1384 | + } |
|
1385 | + |
|
1386 | + /** |
|
1387 | + * Get the locking provider |
|
1388 | + * |
|
1389 | + * @return \OCP\Lock\ILockingProvider |
|
1390 | + * @since 8.1.0 |
|
1391 | + */ |
|
1392 | + public function getLockingProvider() { |
|
1393 | + return $this->query('LockingProvider'); |
|
1394 | + } |
|
1395 | + |
|
1396 | + /** |
|
1397 | + * @return \OCP\Files\Mount\IMountManager |
|
1398 | + **/ |
|
1399 | + function getMountManager() { |
|
1400 | + return $this->query('MountManager'); |
|
1401 | + } |
|
1402 | + |
|
1403 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1404 | + function getUserMountCache() { |
|
1405 | + return $this->query('UserMountCache'); |
|
1406 | + } |
|
1407 | + |
|
1408 | + /** |
|
1409 | + * Get the MimeTypeDetector |
|
1410 | + * |
|
1411 | + * @return \OCP\Files\IMimeTypeDetector |
|
1412 | + */ |
|
1413 | + public function getMimeTypeDetector() { |
|
1414 | + return $this->query('MimeTypeDetector'); |
|
1415 | + } |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * Get the MimeTypeLoader |
|
1419 | + * |
|
1420 | + * @return \OCP\Files\IMimeTypeLoader |
|
1421 | + */ |
|
1422 | + public function getMimeTypeLoader() { |
|
1423 | + return $this->query('MimeTypeLoader'); |
|
1424 | + } |
|
1425 | + |
|
1426 | + /** |
|
1427 | + * Get the manager of all the capabilities |
|
1428 | + * |
|
1429 | + * @return \OC\CapabilitiesManager |
|
1430 | + */ |
|
1431 | + public function getCapabilitiesManager() { |
|
1432 | + return $this->query('CapabilitiesManager'); |
|
1433 | + } |
|
1434 | + |
|
1435 | + /** |
|
1436 | + * Get the EventDispatcher |
|
1437 | + * |
|
1438 | + * @return EventDispatcherInterface |
|
1439 | + * @since 8.2.0 |
|
1440 | + */ |
|
1441 | + public function getEventDispatcher() { |
|
1442 | + return $this->query('EventDispatcher'); |
|
1443 | + } |
|
1444 | + |
|
1445 | + /** |
|
1446 | + * Get the Notification Manager |
|
1447 | + * |
|
1448 | + * @return \OCP\Notification\IManager |
|
1449 | + * @since 8.2.0 |
|
1450 | + */ |
|
1451 | + public function getNotificationManager() { |
|
1452 | + return $this->query('NotificationManager'); |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * @return \OCP\Comments\ICommentsManager |
|
1457 | + */ |
|
1458 | + public function getCommentsManager() { |
|
1459 | + return $this->query('CommentsManager'); |
|
1460 | + } |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * @return \OC_Defaults |
|
1464 | + */ |
|
1465 | + public function getThemingDefaults() { |
|
1466 | + return $this->query('ThemingDefaults'); |
|
1467 | + } |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * @return \OC\IntegrityCheck\Checker |
|
1471 | + */ |
|
1472 | + public function getIntegrityCodeChecker() { |
|
1473 | + return $this->query('IntegrityCodeChecker'); |
|
1474 | + } |
|
1475 | + |
|
1476 | + /** |
|
1477 | + * @return \OC\Session\CryptoWrapper |
|
1478 | + */ |
|
1479 | + public function getSessionCryptoWrapper() { |
|
1480 | + return $this->query('CryptoWrapper'); |
|
1481 | + } |
|
1482 | + |
|
1483 | + /** |
|
1484 | + * @return CsrfTokenManager |
|
1485 | + */ |
|
1486 | + public function getCsrfTokenManager() { |
|
1487 | + return $this->query('CsrfTokenManager'); |
|
1488 | + } |
|
1489 | + |
|
1490 | + /** |
|
1491 | + * @return Throttler |
|
1492 | + */ |
|
1493 | + public function getBruteForceThrottler() { |
|
1494 | + return $this->query('Throttler'); |
|
1495 | + } |
|
1496 | + |
|
1497 | + /** |
|
1498 | + * @return IContentSecurityPolicyManager |
|
1499 | + */ |
|
1500 | + public function getContentSecurityPolicyManager() { |
|
1501 | + return $this->query('ContentSecurityPolicyManager'); |
|
1502 | + } |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * @return ContentSecurityPolicyNonceManager |
|
1506 | + */ |
|
1507 | + public function getContentSecurityPolicyNonceManager() { |
|
1508 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1509 | + } |
|
1510 | + |
|
1511 | + /** |
|
1512 | + * Not a public API as of 8.2, wait for 9.0 |
|
1513 | + * |
|
1514 | + * @return \OCA\Files_External\Service\BackendService |
|
1515 | + */ |
|
1516 | + public function getStoragesBackendService() { |
|
1517 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1518 | + } |
|
1519 | + |
|
1520 | + /** |
|
1521 | + * Not a public API as of 8.2, wait for 9.0 |
|
1522 | + * |
|
1523 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1524 | + */ |
|
1525 | + public function getGlobalStoragesService() { |
|
1526 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1527 | + } |
|
1528 | + |
|
1529 | + /** |
|
1530 | + * Not a public API as of 8.2, wait for 9.0 |
|
1531 | + * |
|
1532 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1533 | + */ |
|
1534 | + public function getUserGlobalStoragesService() { |
|
1535 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1536 | + } |
|
1537 | + |
|
1538 | + /** |
|
1539 | + * Not a public API as of 8.2, wait for 9.0 |
|
1540 | + * |
|
1541 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1542 | + */ |
|
1543 | + public function getUserStoragesService() { |
|
1544 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1545 | + } |
|
1546 | + |
|
1547 | + /** |
|
1548 | + * @return \OCP\Share\IManager |
|
1549 | + */ |
|
1550 | + public function getShareManager() { |
|
1551 | + return $this->query('ShareManager'); |
|
1552 | + } |
|
1553 | + |
|
1554 | + /** |
|
1555 | + * Returns the LDAP Provider |
|
1556 | + * |
|
1557 | + * @return \OCP\LDAP\ILDAPProvider |
|
1558 | + */ |
|
1559 | + public function getLDAPProvider() { |
|
1560 | + return $this->query('LDAPProvider'); |
|
1561 | + } |
|
1562 | + |
|
1563 | + /** |
|
1564 | + * @return \OCP\Settings\IManager |
|
1565 | + */ |
|
1566 | + public function getSettingsManager() { |
|
1567 | + return $this->query('SettingsManager'); |
|
1568 | + } |
|
1569 | + |
|
1570 | + /** |
|
1571 | + * @return \OCP\Files\IAppData |
|
1572 | + */ |
|
1573 | + public function getAppDataDir($app) { |
|
1574 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1575 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1576 | + return $factory->get($app); |
|
1577 | + } |
|
1578 | + |
|
1579 | + /** |
|
1580 | + * @return \OCP\Lockdown\ILockdownManager |
|
1581 | + */ |
|
1582 | + public function getLockdownManager() { |
|
1583 | + return $this->query('LockdownManager'); |
|
1584 | + } |
|
1585 | + |
|
1586 | + /** |
|
1587 | + * @return \OCP\Federation\ICloudIdManager |
|
1588 | + */ |
|
1589 | + public function getCloudIdManager() { |
|
1590 | + return $this->query(ICloudIdManager::class); |
|
1591 | + } |
|
1592 | 1592 | } |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | parent::__construct(); |
123 | 123 | $this->webRoot = $webRoot; |
124 | 124 | |
125 | - $this->registerService('ContactsManager', function ($c) { |
|
125 | + $this->registerService('ContactsManager', function($c) { |
|
126 | 126 | return new ContactsManager(); |
127 | 127 | }); |
128 | 128 | $this->registerAlias(IActionFactory::class, ActionFactory::class); |
129 | 129 | |
130 | - $this->registerService('PreviewManager', function (Server $c) { |
|
130 | + $this->registerService('PreviewManager', function(Server $c) { |
|
131 | 131 | return new PreviewManager( |
132 | 132 | $c->getConfig(), |
133 | 133 | $c->getRootFolder(), |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | ); |
138 | 138 | }); |
139 | 139 | |
140 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
140 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
141 | 141 | return new \OC\Preview\Watcher( |
142 | 142 | $c->getAppDataDir('preview') |
143 | 143 | ); |
144 | 144 | }); |
145 | 145 | |
146 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
146 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
147 | 147 | $view = new View(); |
148 | 148 | $util = new Encryption\Util( |
149 | 149 | $view, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ); |
162 | 162 | }); |
163 | 163 | |
164 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
164 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
165 | 165 | $util = new Encryption\Util( |
166 | 166 | new View(), |
167 | 167 | $c->getUserManager(), |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return new Encryption\File($util); |
172 | 172 | }); |
173 | 173 | |
174 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
174 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
175 | 175 | $view = new View(); |
176 | 176 | $util = new Encryption\Util( |
177 | 177 | $view, |
@@ -182,27 +182,27 @@ discard block |
||
182 | 182 | |
183 | 183 | return new Encryption\Keys\Storage($view, $util); |
184 | 184 | }); |
185 | - $this->registerService('TagMapper', function (Server $c) { |
|
185 | + $this->registerService('TagMapper', function(Server $c) { |
|
186 | 186 | return new TagMapper($c->getDatabaseConnection()); |
187 | 187 | }); |
188 | - $this->registerService('TagManager', function (Server $c) { |
|
188 | + $this->registerService('TagManager', function(Server $c) { |
|
189 | 189 | $tagMapper = $c->query('TagMapper'); |
190 | 190 | return new TagManager($tagMapper, $c->getUserSession()); |
191 | 191 | }); |
192 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
192 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
193 | 193 | $config = $c->getConfig(); |
194 | 194 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
195 | 195 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
196 | 196 | $factory = new $factoryClass($this); |
197 | 197 | return $factory; |
198 | 198 | }); |
199 | - $this->registerService('SystemTagManager', function (Server $c) { |
|
199 | + $this->registerService('SystemTagManager', function(Server $c) { |
|
200 | 200 | return $c->query('SystemTagManagerFactory')->getManager(); |
201 | 201 | }); |
202 | - $this->registerService('SystemTagObjectMapper', function (Server $c) { |
|
202 | + $this->registerService('SystemTagObjectMapper', function(Server $c) { |
|
203 | 203 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
204 | 204 | }); |
205 | - $this->registerService('RootFolder', function (Server $c) { |
|
205 | + $this->registerService('RootFolder', function(Server $c) { |
|
206 | 206 | $manager = \OC\Files\Filesystem::getMountManager(null); |
207 | 207 | $view = new View(); |
208 | 208 | $root = new Root( |
@@ -226,28 +226,28 @@ discard block |
||
226 | 226 | return $c->query('RootFolder'); |
227 | 227 | }); |
228 | 228 | }); |
229 | - $this->registerService('UserManager', function (Server $c) { |
|
229 | + $this->registerService('UserManager', function(Server $c) { |
|
230 | 230 | $config = $c->getConfig(); |
231 | 231 | return new \OC\User\Manager($config); |
232 | 232 | }); |
233 | - $this->registerService('GroupManager', function (Server $c) { |
|
233 | + $this->registerService('GroupManager', function(Server $c) { |
|
234 | 234 | $groupManager = new \OC\Group\Manager($this->getUserManager()); |
235 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
235 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
236 | 236 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
237 | 237 | }); |
238 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
238 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
239 | 239 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
240 | 240 | }); |
241 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
241 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
242 | 242 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
243 | 243 | }); |
244 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
244 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
245 | 245 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
246 | 246 | }); |
247 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
247 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
248 | 248 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
249 | 249 | }); |
250 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
250 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
251 | 251 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
252 | 252 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
253 | 253 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | return new Store($session, $logger, $tokenProvider); |
266 | 266 | }); |
267 | 267 | $this->registerAlias(IStore::class, Store::class); |
268 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
268 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
269 | 269 | $dbConnection = $c->getDatabaseConnection(); |
270 | 270 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
271 | 271 | }); |
272 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
272 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
273 | 273 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
274 | 274 | $crypto = $c->getCrypto(); |
275 | 275 | $config = $c->getConfig(); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
279 | 279 | }); |
280 | 280 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
281 | - $this->registerService('UserSession', function (Server $c) { |
|
281 | + $this->registerService('UserSession', function(Server $c) { |
|
282 | 282 | $manager = $c->getUserManager(); |
283 | 283 | $session = new \OC\Session\Memory(''); |
284 | 284 | $timeFactory = new TimeFactory(); |
@@ -291,70 +291,70 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
294 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
294 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
295 | 295 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
296 | 296 | }); |
297 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
297 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
298 | 298 | /** @var $user \OC\User\User */ |
299 | 299 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
300 | 300 | }); |
301 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
301 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
302 | 302 | /** @var $user \OC\User\User */ |
303 | 303 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
304 | 304 | }); |
305 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
305 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
306 | 306 | /** @var $user \OC\User\User */ |
307 | 307 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
308 | 308 | }); |
309 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
309 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
310 | 310 | /** @var $user \OC\User\User */ |
311 | 311 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
312 | 312 | }); |
313 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
313 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
314 | 314 | /** @var $user \OC\User\User */ |
315 | 315 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
316 | 316 | }); |
317 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
317 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
318 | 318 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
319 | 319 | }); |
320 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
320 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
321 | 321 | /** @var $user \OC\User\User */ |
322 | 322 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
323 | 323 | }); |
324 | - $userSession->listen('\OC\User', 'logout', function () { |
|
324 | + $userSession->listen('\OC\User', 'logout', function() { |
|
325 | 325 | \OC_Hook::emit('OC_User', 'logout', array()); |
326 | 326 | }); |
327 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
327 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
328 | 328 | /** @var $user \OC\User\User */ |
329 | 329 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
330 | 330 | }); |
331 | 331 | return $userSession; |
332 | 332 | }); |
333 | 333 | |
334 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
334 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
335 | 335 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
336 | 336 | }); |
337 | 337 | |
338 | - $this->registerService('NavigationManager', function (Server $c) { |
|
338 | + $this->registerService('NavigationManager', function(Server $c) { |
|
339 | 339 | return new \OC\NavigationManager($c->getAppManager(), |
340 | 340 | $c->getURLGenerator(), |
341 | 341 | $c->getL10NFactory(), |
342 | 342 | $c->getUserSession(), |
343 | 343 | $c->getGroupManager()); |
344 | 344 | }); |
345 | - $this->registerService('AllConfig', function (Server $c) { |
|
345 | + $this->registerService('AllConfig', function(Server $c) { |
|
346 | 346 | return new \OC\AllConfig( |
347 | 347 | $c->getSystemConfig() |
348 | 348 | ); |
349 | 349 | }); |
350 | 350 | $this->registerAlias(\OCP\IConfig::class, 'AllConfig'); |
351 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
351 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
352 | 352 | return new \OC\SystemConfig($config); |
353 | 353 | }); |
354 | - $this->registerService('AppConfig', function (Server $c) { |
|
354 | + $this->registerService('AppConfig', function(Server $c) { |
|
355 | 355 | return new \OC\AppConfig($c->getDatabaseConnection()); |
356 | 356 | }); |
357 | - $this->registerService('L10NFactory', function (Server $c) { |
|
357 | + $this->registerService('L10NFactory', function(Server $c) { |
|
358 | 358 | return new \OC\L10N\Factory( |
359 | 359 | $c->getConfig(), |
360 | 360 | $c->getRequest(), |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | \OC::$SERVERROOT |
363 | 363 | ); |
364 | 364 | }); |
365 | - $this->registerService('URLGenerator', function (Server $c) { |
|
365 | + $this->registerService('URLGenerator', function(Server $c) { |
|
366 | 366 | $config = $c->getConfig(); |
367 | 367 | $cacheFactory = $c->getMemCacheFactory(); |
368 | 368 | return new \OC\URLGenerator( |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | ); |
372 | 372 | }); |
373 | 373 | $this->registerAlias(IURLGenerator::class, 'URLGenerator'); |
374 | - $this->registerService('AppHelper', function ($c) { |
|
374 | + $this->registerService('AppHelper', function($c) { |
|
375 | 375 | return new \OC\AppHelper(); |
376 | 376 | }); |
377 | - $this->registerService('AppFetcher', function ($c) { |
|
377 | + $this->registerService('AppFetcher', function($c) { |
|
378 | 378 | return new AppFetcher( |
379 | 379 | $this->getAppDataDir('appstore'), |
380 | 380 | $this->getHTTPClientService(), |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $this->getConfig() |
383 | 383 | ); |
384 | 384 | }); |
385 | - $this->registerService('CategoryFetcher', function ($c) { |
|
385 | + $this->registerService('CategoryFetcher', function($c) { |
|
386 | 386 | return new CategoryFetcher( |
387 | 387 | $this->getAppDataDir('appstore'), |
388 | 388 | $this->getHTTPClientService(), |
@@ -390,19 +390,19 @@ discard block |
||
390 | 390 | $this->getConfig() |
391 | 391 | ); |
392 | 392 | }); |
393 | - $this->registerService('UserCache', function ($c) { |
|
393 | + $this->registerService('UserCache', function($c) { |
|
394 | 394 | return new Cache\File(); |
395 | 395 | }); |
396 | - $this->registerService('MemCacheFactory', function (Server $c) { |
|
396 | + $this->registerService('MemCacheFactory', function(Server $c) { |
|
397 | 397 | $config = $c->getConfig(); |
398 | 398 | |
399 | 399 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
400 | 400 | $v = \OC_App::getAppVersions(); |
401 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
401 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
402 | 402 | $version = implode(',', $v); |
403 | 403 | $instanceId = \OC_Util::getInstanceId(); |
404 | 404 | $path = \OC::$SERVERROOT; |
405 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
405 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
406 | 406 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
407 | 407 | $config->getSystemValue('memcache.local', null), |
408 | 408 | $config->getSystemValue('memcache.distributed', null), |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | '\\OC\\Memcache\\ArrayCache' |
417 | 417 | ); |
418 | 418 | }); |
419 | - $this->registerService('RedisFactory', function (Server $c) { |
|
419 | + $this->registerService('RedisFactory', function(Server $c) { |
|
420 | 420 | $systemConfig = $c->getSystemConfig(); |
421 | 421 | return new RedisFactory($systemConfig); |
422 | 422 | }); |
423 | - $this->registerService('ActivityManager', function (Server $c) { |
|
423 | + $this->registerService('ActivityManager', function(Server $c) { |
|
424 | 424 | return new \OC\Activity\Manager( |
425 | 425 | $c->getRequest(), |
426 | 426 | $c->getUserSession(), |
@@ -428,13 +428,13 @@ discard block |
||
428 | 428 | $c->query(IValidator::class) |
429 | 429 | ); |
430 | 430 | }); |
431 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
431 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
432 | 432 | return new \OC\Activity\EventMerger( |
433 | 433 | $c->getL10N('lib') |
434 | 434 | ); |
435 | 435 | }); |
436 | 436 | $this->registerAlias(IValidator::class, Validator::class); |
437 | - $this->registerService('AvatarManager', function (Server $c) { |
|
437 | + $this->registerService('AvatarManager', function(Server $c) { |
|
438 | 438 | return new AvatarManager( |
439 | 439 | $c->getUserManager(), |
440 | 440 | $c->getAppDataDir('avatar'), |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | $c->getConfig() |
444 | 444 | ); |
445 | 445 | }); |
446 | - $this->registerService('Logger', function (Server $c) { |
|
446 | + $this->registerService('Logger', function(Server $c) { |
|
447 | 447 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
448 | 448 | $logger = Log::getLogClass($logType); |
449 | 449 | call_user_func(array($logger, 'init')); |
450 | 450 | |
451 | 451 | return new Log($logger); |
452 | 452 | }); |
453 | - $this->registerService('JobList', function (Server $c) { |
|
453 | + $this->registerService('JobList', function(Server $c) { |
|
454 | 454 | $config = $c->getConfig(); |
455 | 455 | return new \OC\BackgroundJob\JobList( |
456 | 456 | $c->getDatabaseConnection(), |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | new TimeFactory() |
459 | 459 | ); |
460 | 460 | }); |
461 | - $this->registerService('Router', function (Server $c) { |
|
461 | + $this->registerService('Router', function(Server $c) { |
|
462 | 462 | $cacheFactory = $c->getMemCacheFactory(); |
463 | 463 | $logger = $c->getLogger(); |
464 | 464 | if ($cacheFactory->isAvailable()) { |
@@ -468,22 +468,22 @@ discard block |
||
468 | 468 | } |
469 | 469 | return $router; |
470 | 470 | }); |
471 | - $this->registerService('Search', function ($c) { |
|
471 | + $this->registerService('Search', function($c) { |
|
472 | 472 | return new Search(); |
473 | 473 | }); |
474 | - $this->registerService('SecureRandom', function ($c) { |
|
474 | + $this->registerService('SecureRandom', function($c) { |
|
475 | 475 | return new SecureRandom(); |
476 | 476 | }); |
477 | - $this->registerService('Crypto', function (Server $c) { |
|
477 | + $this->registerService('Crypto', function(Server $c) { |
|
478 | 478 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
479 | 479 | }); |
480 | - $this->registerService('Hasher', function (Server $c) { |
|
480 | + $this->registerService('Hasher', function(Server $c) { |
|
481 | 481 | return new Hasher($c->getConfig()); |
482 | 482 | }); |
483 | - $this->registerService('CredentialsManager', function (Server $c) { |
|
483 | + $this->registerService('CredentialsManager', function(Server $c) { |
|
484 | 484 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
485 | 485 | }); |
486 | - $this->registerService('DatabaseConnection', function (Server $c) { |
|
486 | + $this->registerService('DatabaseConnection', function(Server $c) { |
|
487 | 487 | $systemConfig = $c->getSystemConfig(); |
488 | 488 | $factory = new \OC\DB\ConnectionFactory($c->getConfig()); |
489 | 489 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
496 | 496 | return $connection; |
497 | 497 | }); |
498 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
498 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
499 | 499 | $config = $c->getConfig(); |
500 | 500 | return new HTTPHelper( |
501 | 501 | $config, |
502 | 502 | $c->getHTTPClientService() |
503 | 503 | ); |
504 | 504 | }); |
505 | - $this->registerService('HttpClientService', function (Server $c) { |
|
505 | + $this->registerService('HttpClientService', function(Server $c) { |
|
506 | 506 | $user = \OC_User::getUser(); |
507 | 507 | $uid = $user ? $user : null; |
508 | 508 | return new ClientService( |
@@ -510,27 +510,27 @@ discard block |
||
510 | 510 | new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
511 | 511 | ); |
512 | 512 | }); |
513 | - $this->registerService('EventLogger', function (Server $c) { |
|
513 | + $this->registerService('EventLogger', function(Server $c) { |
|
514 | 514 | if ($c->getSystemConfig()->getValue('debug', false)) { |
515 | 515 | return new EventLogger(); |
516 | 516 | } else { |
517 | 517 | return new NullEventLogger(); |
518 | 518 | } |
519 | 519 | }); |
520 | - $this->registerService('QueryLogger', function (Server $c) { |
|
520 | + $this->registerService('QueryLogger', function(Server $c) { |
|
521 | 521 | if ($c->getSystemConfig()->getValue('debug', false)) { |
522 | 522 | return new QueryLogger(); |
523 | 523 | } else { |
524 | 524 | return new NullQueryLogger(); |
525 | 525 | } |
526 | 526 | }); |
527 | - $this->registerService('TempManager', function (Server $c) { |
|
527 | + $this->registerService('TempManager', function(Server $c) { |
|
528 | 528 | return new TempManager( |
529 | 529 | $c->getLogger(), |
530 | 530 | $c->getConfig() |
531 | 531 | ); |
532 | 532 | }); |
533 | - $this->registerService('AppManager', function (Server $c) { |
|
533 | + $this->registerService('AppManager', function(Server $c) { |
|
534 | 534 | return new \OC\App\AppManager( |
535 | 535 | $c->getUserSession(), |
536 | 536 | $c->getAppConfig(), |
@@ -539,13 +539,13 @@ discard block |
||
539 | 539 | $c->getEventDispatcher() |
540 | 540 | ); |
541 | 541 | }); |
542 | - $this->registerService('DateTimeZone', function (Server $c) { |
|
542 | + $this->registerService('DateTimeZone', function(Server $c) { |
|
543 | 543 | return new DateTimeZone( |
544 | 544 | $c->getConfig(), |
545 | 545 | $c->getSession() |
546 | 546 | ); |
547 | 547 | }); |
548 | - $this->registerService('DateTimeFormatter', function (Server $c) { |
|
548 | + $this->registerService('DateTimeFormatter', function(Server $c) { |
|
549 | 549 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
550 | 550 | |
551 | 551 | return new DateTimeFormatter( |
@@ -553,16 +553,16 @@ discard block |
||
553 | 553 | $c->getL10N('lib', $language) |
554 | 554 | ); |
555 | 555 | }); |
556 | - $this->registerService('UserMountCache', function (Server $c) { |
|
556 | + $this->registerService('UserMountCache', function(Server $c) { |
|
557 | 557 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
558 | 558 | $listener = new UserMountCacheListener($mountCache); |
559 | 559 | $listener->listen($c->getUserManager()); |
560 | 560 | return $mountCache; |
561 | 561 | }); |
562 | - $this->registerService('MountConfigManager', function (Server $c) { |
|
562 | + $this->registerService('MountConfigManager', function(Server $c) { |
|
563 | 563 | $loader = \OC\Files\Filesystem::getLoader(); |
564 | 564 | $mountCache = $c->query('UserMountCache'); |
565 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
565 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
566 | 566 | |
567 | 567 | // builtin providers |
568 | 568 | |
@@ -573,14 +573,14 @@ discard block |
||
573 | 573 | |
574 | 574 | return $manager; |
575 | 575 | }); |
576 | - $this->registerService('IniWrapper', function ($c) { |
|
576 | + $this->registerService('IniWrapper', function($c) { |
|
577 | 577 | return new IniGetWrapper(); |
578 | 578 | }); |
579 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
579 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
580 | 580 | $jobList = $c->getJobList(); |
581 | 581 | return new AsyncBus($jobList); |
582 | 582 | }); |
583 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
583 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
584 | 584 | return new TrustedDomainHelper($this->getConfig()); |
585 | 585 | }); |
586 | 586 | $this->registerService('Throttler', function(Server $c) { |
@@ -591,10 +591,10 @@ discard block |
||
591 | 591 | $c->getConfig() |
592 | 592 | ); |
593 | 593 | }); |
594 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
594 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
595 | 595 | // IConfig and IAppManager requires a working database. This code |
596 | 596 | // might however be called when ownCloud is not yet setup. |
597 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
597 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
598 | 598 | $config = $c->getConfig(); |
599 | 599 | $appManager = $c->getAppManager(); |
600 | 600 | } else { |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | $c->getTempManager() |
613 | 613 | ); |
614 | 614 | }); |
615 | - $this->registerService('Request', function ($c) { |
|
615 | + $this->registerService('Request', function($c) { |
|
616 | 616 | if (isset($this['urlParams'])) { |
617 | 617 | $urlParams = $this['urlParams']; |
618 | 618 | } else { |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | $stream |
647 | 647 | ); |
648 | 648 | }); |
649 | - $this->registerService('Mailer', function (Server $c) { |
|
649 | + $this->registerService('Mailer', function(Server $c) { |
|
650 | 650 | return new Mailer( |
651 | 651 | $c->getConfig(), |
652 | 652 | $c->getLogger(), |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | $this->registerService('LDAPProvider', function(Server $c) { |
657 | 657 | $config = $c->getConfig(); |
658 | 658 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
659 | - if(is_null($factoryClass)) { |
|
659 | + if (is_null($factoryClass)) { |
|
660 | 660 | throw new \Exception('ldapProviderFactory not set'); |
661 | 661 | } |
662 | 662 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
663 | 663 | $factory = new $factoryClass($this); |
664 | 664 | return $factory->getLDAPProvider(); |
665 | 665 | }); |
666 | - $this->registerService('LockingProvider', function (Server $c) { |
|
666 | + $this->registerService('LockingProvider', function(Server $c) { |
|
667 | 667 | $ini = $c->getIniWrapper(); |
668 | 668 | $config = $c->getConfig(); |
669 | 669 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -678,29 +678,29 @@ discard block |
||
678 | 678 | } |
679 | 679 | return new NoopLockingProvider(); |
680 | 680 | }); |
681 | - $this->registerService('MountManager', function () { |
|
681 | + $this->registerService('MountManager', function() { |
|
682 | 682 | return new \OC\Files\Mount\Manager(); |
683 | 683 | }); |
684 | - $this->registerService('MimeTypeDetector', function (Server $c) { |
|
684 | + $this->registerService('MimeTypeDetector', function(Server $c) { |
|
685 | 685 | return new \OC\Files\Type\Detection( |
686 | 686 | $c->getURLGenerator(), |
687 | 687 | \OC::$configDir, |
688 | - \OC::$SERVERROOT . '/resources/config/' |
|
688 | + \OC::$SERVERROOT.'/resources/config/' |
|
689 | 689 | ); |
690 | 690 | }); |
691 | - $this->registerService('MimeTypeLoader', function (Server $c) { |
|
691 | + $this->registerService('MimeTypeLoader', function(Server $c) { |
|
692 | 692 | return new \OC\Files\Type\Loader( |
693 | 693 | $c->getDatabaseConnection() |
694 | 694 | ); |
695 | 695 | }); |
696 | - $this->registerService('NotificationManager', function (Server $c) { |
|
696 | + $this->registerService('NotificationManager', function(Server $c) { |
|
697 | 697 | return new Manager( |
698 | 698 | $c->query(IValidator::class) |
699 | 699 | ); |
700 | 700 | }); |
701 | - $this->registerService('CapabilitiesManager', function (Server $c) { |
|
701 | + $this->registerService('CapabilitiesManager', function(Server $c) { |
|
702 | 702 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
703 | - $manager->registerCapability(function () use ($c) { |
|
703 | + $manager->registerCapability(function() use ($c) { |
|
704 | 704 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
705 | 705 | }); |
706 | 706 | return $manager; |
@@ -738,10 +738,10 @@ discard block |
||
738 | 738 | } |
739 | 739 | return new \OC_Defaults(); |
740 | 740 | }); |
741 | - $this->registerService('EventDispatcher', function () { |
|
741 | + $this->registerService('EventDispatcher', function() { |
|
742 | 742 | return new EventDispatcher(); |
743 | 743 | }); |
744 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
744 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
745 | 745 | // FIXME: Instantiiated here due to cyclic dependency |
746 | 746 | $request = new Request( |
747 | 747 | [ |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | $request |
767 | 767 | ); |
768 | 768 | }); |
769 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
769 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
770 | 770 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
771 | 771 | |
772 | 772 | return new CsrfTokenManager( |
@@ -774,10 +774,10 @@ discard block |
||
774 | 774 | $c->query(SessionStorage::class) |
775 | 775 | ); |
776 | 776 | }); |
777 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
777 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
778 | 778 | return new SessionStorage($c->getSession()); |
779 | 779 | }); |
780 | - $this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
|
780 | + $this->registerService('ContentSecurityPolicyManager', function(Server $c) { |
|
781 | 781 | return new ContentSecurityPolicyManager(); |
782 | 782 | }); |
783 | 783 | $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
@@ -822,23 +822,23 @@ discard block |
||
822 | 822 | ); |
823 | 823 | return $manager; |
824 | 824 | }); |
825 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
825 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
826 | 826 | return new \OC\Files\AppData\Factory( |
827 | 827 | $c->getRootFolder(), |
828 | 828 | $c->getSystemConfig() |
829 | 829 | ); |
830 | 830 | }); |
831 | 831 | |
832 | - $this->registerService('LockdownManager', function (Server $c) { |
|
832 | + $this->registerService('LockdownManager', function(Server $c) { |
|
833 | 833 | return new LockdownManager(); |
834 | 834 | }); |
835 | 835 | |
836 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
836 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
837 | 837 | return new CloudIdManager(); |
838 | 838 | }); |
839 | 839 | |
840 | 840 | /* To trick DI since we don't extend the DIContainer here */ |
841 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
841 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
842 | 842 | return new CleanPreviewsBackgroundJob( |
843 | 843 | $c->getRootFolder(), |
844 | 844 | $c->getLogger(), |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @deprecated since 9.2.0 use IAppData |
983 | 983 | */ |
984 | 984 | public function getAppFolder() { |
985 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
985 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
986 | 986 | $root = $this->getRootFolder(); |
987 | 987 | if (!$root->nodeExists($dir)) { |
988 | 988 | $folder = $root->newFolder($dir); |