Completed
Pull Request — master (#6637)
by Tobia
13:14
created
lib/private/Contacts/ContactsMenu/ContactsStore.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -25,14 +25,12 @@
 block discarded – undo
25 25
 
26 26
 namespace OC\Contacts\ContactsMenu;
27 27
 
28
-use OC\Share\Share;
29 28
 use OCP\Contacts\ContactsMenu\IEntry;
30 29
 use OCP\Contacts\IManager;
31 30
 use OCP\IConfig;
32 31
 use OCP\IGroupManager;
33 32
 use OCP\IUser;
34 33
 use OCP\IUserManager;
35
-use OCP\IUserSession;
36 34
 use OCP\Contacts\ContactsMenu\IContactsStore;
37 35
 
38 36
 class ContactsStore implements IContactsStore {
Please login to merge, or discard this patch.
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -37,220 +37,220 @@
 block discarded – undo
37 37
 
38 38
 class ContactsStore implements IContactsStore {
39 39
 
40
-	/** @var IManager */
41
-	private $contactsManager;
42
-
43
-	/** @var IConfig */
44
-	private $config;
45
-
46
-	/** @var IUserManager */
47
-	private $userManager;
48
-
49
-	/** @var IGroupManager */
50
-	private $groupManager;
51
-
52
-	/**
53
-	 * @param IManager $contactsManager
54
-	 * @param IConfig $config
55
-	 * @param IUserManager $userManager
56
-	 * @param IGroupManager $groupManager
57
-	 */
58
-	public function __construct(IManager $contactsManager,
59
-								IConfig $config,
60
-								IUserManager $userManager,
61
-								IGroupManager $groupManager) {
62
-		$this->contactsManager = $contactsManager;
63
-		$this->config = $config;
64
-		$this->userManager = $userManager;
65
-		$this->groupManager = $groupManager;
66
-	}
67
-
68
-	/**
69
-	 * @param IUser $user
70
-	 * @param string|null $filter
71
-	 * @return IEntry[]
72
-	 */
73
-	public function getContacts(IUser $user, $filter) {
74
-		$allContacts = $this->contactsManager->search($filter ?: '', [
75
-			'FN',
76
-			'EMAIL'
77
-		]);
78
-
79
-		$entries = array_map(function(array $contact) {
80
-			return $this->contactArrayToEntry($contact);
81
-		}, $allContacts);
82
-		return $this->filterContacts(
83
-			$user,
84
-			$entries,
85
-			$filter
86
-		);
87
-	}
88
-
89
-	/**
90
-	 * Filters the contacts. Applies 3 filters:
91
-	 *  1. filter the current user
92
-	 *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
93
-	 * enabled it will filter all local users
94
-	 *  3. if the `shareapi_exclude_groups` config option is enabled and the
95
-	 * current user is in an excluded group it will filter all local users.
96
-	 *  4. if the `shareapi_only_share_with_group_members` config option is
97
-	 * enabled it will filter all users which doens't have a common group
98
-	 * with the current user.
99
-	 *
100
-	 * @param IUser $self
101
-	 * @param Entry[] $entries
102
-	 * @param string $filter
103
-	 * @return Entry[] the filtered contacts
104
-	 */
105
-	private function filterContacts(IUser $self,
106
-									array $entries,
107
-									$filter) {
108
-		$disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
109
-		$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
110
-
111
-		// whether to filter out local users
112
-		$skipLocal = false;
113
-		// whether to filter out all users which doesn't have the same group as the current user
114
-		$ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
115
-
116
-		$selfGroups = $this->groupManager->getUserGroupIds($self);
117
-
118
-		if ($excludedGroups) {
119
-			$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
120
-			$decodedExcludeGroups = json_decode($excludedGroups, true);
121
-			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
122
-
123
-			if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
124
-				// a group of the current user is excluded -> filter all local users
125
-				$skipLocal = true;
126
-			}
127
-		}
128
-
129
-		$selfUID = $self->getUID();
130
-
131
-		return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
132
-			if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
133
-				return false;
134
-			}
135
-
136
-			// Prevent enumerating local users
137
-			if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
138
-				$filterUser = true;
139
-
140
-				$mailAddresses = $entry->getEMailAddresses();
141
-				foreach($mailAddresses as $mailAddress) {
142
-					if($mailAddress === $filter) {
143
-						$filterUser = false;
144
-						break;
145
-					}
146
-				}
147
-
148
-				if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
149
-					$filterUser = false;
150
-				}
151
-
152
-				if($filterUser) {
153
-					return false;
154
-				}
155
-			}
156
-
157
-			if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
158
-				$contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));
159
-				if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
160
-					// no groups in common, so shouldn't see the contact
161
-					return false;
162
-				}
163
-			}
164
-
165
-			return $entry->getProperty('UID') !== $selfUID;
166
-		}));
167
-	}
168
-
169
-	/**
170
-	 * @param IUser $user
171
-	 * @param integer $shareType
172
-	 * @param string $shareWith
173
-	 * @return IEntry|null
174
-	 */
175
-	public function findOne(IUser $user, $shareType, $shareWith) {
176
-		switch($shareType) {
177
-			case 0:
178
-			case 6:
179
-				$filter = ['UID'];
180
-				break;
181
-			case 4:
182
-				$filter = ['EMAIL'];
183
-				break;
184
-			default:
185
-				return null;
186
-		}
187
-
188
-		$userId = $user->getUID();
189
-		$allContacts = $this->contactsManager->search($shareWith, $filter);
190
-		$contacts = array_filter($allContacts, function($contact) use ($userId) {
191
-			return $contact['UID'] !== $userId;
192
-		});
193
-		$match = null;
194
-
195
-		foreach ($contacts as $contact) {
196
-			if ($shareType === 4 && isset($contact['EMAIL'])) {
197
-				if (in_array($shareWith, $contact['EMAIL'])) {
198
-					$match = $contact;
199
-					break;
200
-				}
201
-			}
202
-			if ($shareType === 0 || $shareType === 6) {
203
-				if ($contact['UID'] === $shareWith && $contact['isLocalSystemBook'] === true) {
204
-					$match = $contact;
205
-					break;
206
-				}
207
-			}
208
-		}
209
-
210
-		if ($match) {
211
-			$match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
212
-			if (count($match) === 1) {
213
-				$match = $match[0];
214
-			} else {
215
-				$match = null;
216
-			}
217
-
218
-		}
219
-
220
-		return $match;
221
-	}
222
-
223
-	/**
224
-	 * @param array $contact
225
-	 * @return Entry
226
-	 */
227
-	private function contactArrayToEntry(array $contact) {
228
-		$entry = new Entry();
229
-
230
-		if (isset($contact['id'])) {
231
-			$entry->setId($contact['id']);
232
-		}
233
-
234
-		if (isset($contact['FN'])) {
235
-			$entry->setFullName($contact['FN']);
236
-		}
237
-
238
-		$avatarPrefix = "VALUE=uri:";
239
-		if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
240
-			$entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
241
-		}
242
-
243
-		if (isset($contact['EMAIL'])) {
244
-			foreach ($contact['EMAIL'] as $email) {
245
-				$entry->addEMailAddress($email);
246
-			}
247
-		}
248
-
249
-		// Attach all other properties to the entry too because some
250
-		// providers might make use of it.
251
-		$entry->setProperties($contact);
252
-
253
-		return $entry;
254
-	}
40
+    /** @var IManager */
41
+    private $contactsManager;
42
+
43
+    /** @var IConfig */
44
+    private $config;
45
+
46
+    /** @var IUserManager */
47
+    private $userManager;
48
+
49
+    /** @var IGroupManager */
50
+    private $groupManager;
51
+
52
+    /**
53
+     * @param IManager $contactsManager
54
+     * @param IConfig $config
55
+     * @param IUserManager $userManager
56
+     * @param IGroupManager $groupManager
57
+     */
58
+    public function __construct(IManager $contactsManager,
59
+                                IConfig $config,
60
+                                IUserManager $userManager,
61
+                                IGroupManager $groupManager) {
62
+        $this->contactsManager = $contactsManager;
63
+        $this->config = $config;
64
+        $this->userManager = $userManager;
65
+        $this->groupManager = $groupManager;
66
+    }
67
+
68
+    /**
69
+     * @param IUser $user
70
+     * @param string|null $filter
71
+     * @return IEntry[]
72
+     */
73
+    public function getContacts(IUser $user, $filter) {
74
+        $allContacts = $this->contactsManager->search($filter ?: '', [
75
+            'FN',
76
+            'EMAIL'
77
+        ]);
78
+
79
+        $entries = array_map(function(array $contact) {
80
+            return $this->contactArrayToEntry($contact);
81
+        }, $allContacts);
82
+        return $this->filterContacts(
83
+            $user,
84
+            $entries,
85
+            $filter
86
+        );
87
+    }
88
+
89
+    /**
90
+     * Filters the contacts. Applies 3 filters:
91
+     *  1. filter the current user
92
+     *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
93
+     * enabled it will filter all local users
94
+     *  3. if the `shareapi_exclude_groups` config option is enabled and the
95
+     * current user is in an excluded group it will filter all local users.
96
+     *  4. if the `shareapi_only_share_with_group_members` config option is
97
+     * enabled it will filter all users which doens't have a common group
98
+     * with the current user.
99
+     *
100
+     * @param IUser $self
101
+     * @param Entry[] $entries
102
+     * @param string $filter
103
+     * @return Entry[] the filtered contacts
104
+     */
105
+    private function filterContacts(IUser $self,
106
+                                    array $entries,
107
+                                    $filter) {
108
+        $disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
109
+        $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
110
+
111
+        // whether to filter out local users
112
+        $skipLocal = false;
113
+        // whether to filter out all users which doesn't have the same group as the current user
114
+        $ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
115
+
116
+        $selfGroups = $this->groupManager->getUserGroupIds($self);
117
+
118
+        if ($excludedGroups) {
119
+            $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
120
+            $decodedExcludeGroups = json_decode($excludedGroups, true);
121
+            $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
122
+
123
+            if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
124
+                // a group of the current user is excluded -> filter all local users
125
+                $skipLocal = true;
126
+            }
127
+        }
128
+
129
+        $selfUID = $self->getUID();
130
+
131
+        return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
132
+            if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
133
+                return false;
134
+            }
135
+
136
+            // Prevent enumerating local users
137
+            if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
138
+                $filterUser = true;
139
+
140
+                $mailAddresses = $entry->getEMailAddresses();
141
+                foreach($mailAddresses as $mailAddress) {
142
+                    if($mailAddress === $filter) {
143
+                        $filterUser = false;
144
+                        break;
145
+                    }
146
+                }
147
+
148
+                if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
149
+                    $filterUser = false;
150
+                }
151
+
152
+                if($filterUser) {
153
+                    return false;
154
+                }
155
+            }
156
+
157
+            if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
158
+                $contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));
159
+                if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
160
+                    // no groups in common, so shouldn't see the contact
161
+                    return false;
162
+                }
163
+            }
164
+
165
+            return $entry->getProperty('UID') !== $selfUID;
166
+        }));
167
+    }
168
+
169
+    /**
170
+     * @param IUser $user
171
+     * @param integer $shareType
172
+     * @param string $shareWith
173
+     * @return IEntry|null
174
+     */
175
+    public function findOne(IUser $user, $shareType, $shareWith) {
176
+        switch($shareType) {
177
+            case 0:
178
+            case 6:
179
+                $filter = ['UID'];
180
+                break;
181
+            case 4:
182
+                $filter = ['EMAIL'];
183
+                break;
184
+            default:
185
+                return null;
186
+        }
187
+
188
+        $userId = $user->getUID();
189
+        $allContacts = $this->contactsManager->search($shareWith, $filter);
190
+        $contacts = array_filter($allContacts, function($contact) use ($userId) {
191
+            return $contact['UID'] !== $userId;
192
+        });
193
+        $match = null;
194
+
195
+        foreach ($contacts as $contact) {
196
+            if ($shareType === 4 && isset($contact['EMAIL'])) {
197
+                if (in_array($shareWith, $contact['EMAIL'])) {
198
+                    $match = $contact;
199
+                    break;
200
+                }
201
+            }
202
+            if ($shareType === 0 || $shareType === 6) {
203
+                if ($contact['UID'] === $shareWith && $contact['isLocalSystemBook'] === true) {
204
+                    $match = $contact;
205
+                    break;
206
+                }
207
+            }
208
+        }
209
+
210
+        if ($match) {
211
+            $match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
212
+            if (count($match) === 1) {
213
+                $match = $match[0];
214
+            } else {
215
+                $match = null;
216
+            }
217
+
218
+        }
219
+
220
+        return $match;
221
+    }
222
+
223
+    /**
224
+     * @param array $contact
225
+     * @return Entry
226
+     */
227
+    private function contactArrayToEntry(array $contact) {
228
+        $entry = new Entry();
229
+
230
+        if (isset($contact['id'])) {
231
+            $entry->setId($contact['id']);
232
+        }
233
+
234
+        if (isset($contact['FN'])) {
235
+            $entry->setFullName($contact['FN']);
236
+        }
237
+
238
+        $avatarPrefix = "VALUE=uri:";
239
+        if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
240
+            $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
241
+        }
242
+
243
+        if (isset($contact['EMAIL'])) {
244
+            foreach ($contact['EMAIL'] as $email) {
245
+                $entry->addEMailAddress($email);
246
+            }
247
+        }
248
+
249
+        // Attach all other properties to the entry too because some
250
+        // providers might make use of it.
251
+        $entry->setProperties($contact);
252
+
253
+        return $entry;
254
+    }
255 255
 
256 256
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/ContactsManager.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,60 +29,60 @@
 block discarded – undo
29 29
 use OCP\IURLGenerator;
30 30
 
31 31
 class ContactsManager {
32
-	/** @var CardDavBackend  */
33
-	private $backend;
32
+    /** @var CardDavBackend  */
33
+    private $backend;
34 34
 
35
-	/** @var IL10N  */
36
-	private $l10n;
35
+    /** @var IL10N  */
36
+    private $l10n;
37 37
 
38
-	/**
39
-	 * ContactsManager constructor.
40
-	 *
41
-	 * @param CardDavBackend $backend
42
-	 * @param IL10N $l10n
43
-	 */
44
-	public function __construct(CardDavBackend $backend, IL10N $l10n) {
45
-		$this->backend = $backend;
46
-		$this->l10n = $l10n;
47
-	}
38
+    /**
39
+     * ContactsManager constructor.
40
+     *
41
+     * @param CardDavBackend $backend
42
+     * @param IL10N $l10n
43
+     */
44
+    public function __construct(CardDavBackend $backend, IL10N $l10n) {
45
+        $this->backend = $backend;
46
+        $this->l10n = $l10n;
47
+    }
48 48
 
49
-	/**
50
-	 * @param IManager $cm
51
-	 * @param string $userId
52
-	 * @param IURLGenerator $urlGenerator
53
-	 */
54
-	public function setupContactsProvider(IManager $cm, $userId, IURLGenerator $urlGenerator) {
55
-		$addressBooks = $this->backend->getAddressBooksForUser("principals/users/$userId");
56
-		$this->register($cm, $addressBooks, $urlGenerator);
57
-		$this->setupSystemContactsProvider($cm, $urlGenerator);
58
-	}
49
+    /**
50
+     * @param IManager $cm
51
+     * @param string $userId
52
+     * @param IURLGenerator $urlGenerator
53
+     */
54
+    public function setupContactsProvider(IManager $cm, $userId, IURLGenerator $urlGenerator) {
55
+        $addressBooks = $this->backend->getAddressBooksForUser("principals/users/$userId");
56
+        $this->register($cm, $addressBooks, $urlGenerator);
57
+        $this->setupSystemContactsProvider($cm, $urlGenerator);
58
+    }
59 59
 
60
-	/**
61
-	 * @param IManager $cm
62
-	 * @param IURLGenerator $urlGenerator
63
-	 */
64
-	public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGenerator) {
65
-		$addressBooks = $this->backend->getAddressBooksForUser("principals/system/system");
66
-		$this->register($cm, $addressBooks, $urlGenerator);
67
-	}
60
+    /**
61
+     * @param IManager $cm
62
+     * @param IURLGenerator $urlGenerator
63
+     */
64
+    public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGenerator) {
65
+        $addressBooks = $this->backend->getAddressBooksForUser("principals/system/system");
66
+        $this->register($cm, $addressBooks, $urlGenerator);
67
+    }
68 68
 
69
-	/**
70
-	 * @param IManager $cm
71
-	 * @param $addressBooks
72
-	 * @param IURLGenerator $urlGenerator
73
-	 */
74
-	private function register(IManager $cm, $addressBooks, $urlGenerator) {
75
-		foreach ($addressBooks as $addressBookInfo) {
76
-			$addressBook = new \OCA\DAV\CardDAV\AddressBook($this->backend, $addressBookInfo, $this->l10n);
77
-			$cm->registerAddressBook(
78
-				new AddressBookImpl(
79
-					$addressBook,
80
-					$addressBookInfo,
81
-					$this->backend,
82
-					$urlGenerator
83
-				)
84
-			);
85
-		}
86
-	}
69
+    /**
70
+     * @param IManager $cm
71
+     * @param $addressBooks
72
+     * @param IURLGenerator $urlGenerator
73
+     */
74
+    private function register(IManager $cm, $addressBooks, $urlGenerator) {
75
+        foreach ($addressBooks as $addressBookInfo) {
76
+            $addressBook = new \OCA\DAV\CardDAV\AddressBook($this->backend, $addressBookInfo, $this->l10n);
77
+            $cm->registerAddressBook(
78
+                new AddressBookImpl(
79
+                    $addressBook,
80
+                    $addressBookInfo,
81
+                    $this->backend,
82
+                    $urlGenerator
83
+                )
84
+            );
85
+        }
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IContactsStore.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@
 block discarded – undo
10 10
 interface IContactsStore {
11 11
 
12 12
 
13
-	/**
14
-	 * @param IUser $user
15
-	 * @param $filter
16
-	 * @return IEntry[]
17
-	 * @since 13.0.0
18
-	 */
19
-	public function getContacts(IUser $user, $filter);
13
+    /**
14
+     * @param IUser $user
15
+     * @param $filter
16
+     * @return IEntry[]
17
+     * @since 13.0.0
18
+     */
19
+    public function getContacts(IUser $user, $filter);
20 20
 
21
-	/**
22
-	 * @brief finds a contact by specifying the property to search on ($shareType) and the value ($shareWith)
23
-	 * @param IUser $user
24
-	 * @param integer $shareType
25
-	 * @param string $shareWith
26
-	 * @return IEntry|null
27
-	 * @since 13.0.0
28
-	 */
29
-	public function findOne(IUser $user, $shareType, $shareWith);
21
+    /**
22
+     * @brief finds a contact by specifying the property to search on ($shareType) and the value ($shareWith)
23
+     * @param IUser $user
24
+     * @param integer $shareType
25
+     * @param string $shareWith
26
+     * @return IEntry|null
27
+     * @since 13.0.0
28
+     */
29
+    public function findOne(IUser $user, $shareType, $shareWith);
30 30
 
31 31
 }
Please login to merge, or discard this patch.
apps/dav/lib/AppInfo/Application.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	 * @param IManager $contactsManager
79
+	 * @param IContactsManager $contactsManager
80 80
 	 */
81 81
 	public function setupSystemContactsProvider(IContactsManager $contactsManager) {
82 82
 		/** @var ContactsManager $cm */
Please login to merge, or discard this patch.
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -43,175 +43,175 @@
 block discarded – undo
43 43
 
44 44
 class Application extends App {
45 45
 
46
-	/**
47
-	 * Application constructor.
48
-	 */
49
-	public function __construct() {
50
-		parent::__construct('dav');
51
-
52
-		$container = $this->getContainer();
53
-		$server = $container->getServer();
54
-
55
-		$container->registerService(PhotoCache::class, function(SimpleContainer $s) use ($server) {
56
-			return new PhotoCache(
57
-				$server->getAppDataDir('dav-photocache')
58
-			);
59
-		});
60
-
61
-		/*
46
+    /**
47
+     * Application constructor.
48
+     */
49
+    public function __construct() {
50
+        parent::__construct('dav');
51
+
52
+        $container = $this->getContainer();
53
+        $server = $container->getServer();
54
+
55
+        $container->registerService(PhotoCache::class, function(SimpleContainer $s) use ($server) {
56
+            return new PhotoCache(
57
+                $server->getAppDataDir('dav-photocache')
58
+            );
59
+        });
60
+
61
+        /*
62 62
 		 * Register capabilities
63 63
 		 */
64
-		$container->registerCapability(Capabilities::class);
65
-	}
66
-
67
-	/**
68
-	 * @param IContactsManager $contactsManager
69
-	 * @param string $userID
70
-	 */
71
-	public function setupContactsProvider(IContactsManager $contactsManager, $userID) {
72
-		/** @var ContactsManager $cm */
73
-		$cm = $this->getContainer()->query(ContactsManager::class);
74
-		$urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
75
-		$cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
76
-	}
77
-
78
-	/**
79
-	 * @param IManager $contactsManager
80
-	 */
81
-	public function setupSystemContactsProvider(IContactsManager $contactsManager) {
82
-		/** @var ContactsManager $cm */
83
-		$cm = $this->getContainer()->query(ContactsManager::class);
84
-		$urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
85
-		$cm->setupSystemContactsProvider($contactsManager, $urlGenerator);
86
-	}
87
-
88
-	/**
89
-	 * @param ICalendarManager $calendarManager
90
-	 * @param string $userId
91
-	 */
92
-	public function setupCalendarProvider(ICalendarManager $calendarManager, $userId) {
93
-		$cm = $this->getContainer()->query(CalendarManager::class);
94
-		$cm->setupCalendarProvider($calendarManager, $userId);
95
-	}
96
-
97
-	public function registerHooks() {
98
-		/** @var HookManager $hm */
99
-		$hm = $this->getContainer()->query(HookManager::class);
100
-		$hm->setup();
101
-
102
-		$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
103
-
104
-		// first time login event setup
105
-		$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
106
-			if ($event instanceof GenericEvent) {
107
-				$hm->firstLogin($event->getSubject());
108
-			}
109
-		});
110
-
111
-		// carddav/caldav sync event setup
112
-		$listener = function($event) {
113
-			if ($event instanceof GenericEvent) {
114
-				/** @var BirthdayService $b */
115
-				$b = $this->getContainer()->query(BirthdayService::class);
116
-				$b->onCardChanged(
117
-					$event->getArgument('addressBookId'),
118
-					$event->getArgument('cardUri'),
119
-					$event->getArgument('cardData')
120
-				);
121
-			}
122
-		};
123
-
124
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
125
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
126
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
127
-			if ($event instanceof GenericEvent) {
128
-				/** @var BirthdayService $b */
129
-				$b = $this->getContainer()->query(BirthdayService::class);
130
-				$b->onCardDeleted(
131
-					$event->getArgument('addressBookId'),
132
-					$event->getArgument('cardUri')
133
-				);
134
-			}
135
-		});
136
-
137
-		$clearPhotoCache = function($event) {
138
-			if ($event instanceof GenericEvent) {
139
-				/** @var PhotoCache $p */
140
-				$p = $this->getContainer()->query(PhotoCache::class);
141
-				$p->delete(
142
-					$event->getArgument('addressBookId'),
143
-					$event->getArgument('cardUri')
144
-				);
145
-			}
146
-		};
147
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $clearPhotoCache);
148
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $clearPhotoCache);
149
-
150
-		$dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) {
151
-			$user = $event->getSubject();
152
-			$syncService = $this->getContainer()->query(SyncService::class);
153
-			$syncService->updateUser($user);
154
-		});
155
-
156
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
157
-			/** @var Backend $backend */
158
-			$backend = $this->getContainer()->query(Backend::class);
159
-			$backend->onCalendarAdd(
160
-				$event->getArgument('calendarData')
161
-			);
162
-		});
163
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) {
164
-			/** @var Backend $backend */
165
-			$backend = $this->getContainer()->query(Backend::class);
166
-			$backend->onCalendarUpdate(
167
-				$event->getArgument('calendarData'),
168
-				$event->getArgument('shares'),
169
-				$event->getArgument('propertyMutations')
170
-			);
171
-		});
172
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) {
173
-			/** @var Backend $backend */
174
-			$backend = $this->getContainer()->query(Backend::class);
175
-			$backend->onCalendarDelete(
176
-				$event->getArgument('calendarData'),
177
-				$event->getArgument('shares')
178
-			);
179
-		});
180
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
181
-			/** @var Backend $backend */
182
-			$backend = $this->getContainer()->query(Backend::class);
183
-			$backend->onCalendarUpdateShares(
184
-				$event->getArgument('calendarData'),
185
-				$event->getArgument('shares'),
186
-				$event->getArgument('add'),
187
-				$event->getArgument('remove')
188
-			);
189
-		});
190
-
191
-		$listener = function(GenericEvent $event, $eventName) {
192
-			/** @var Backend $backend */
193
-			$backend = $this->getContainer()->query(Backend::class);
194
-
195
-			$subject = Event::SUBJECT_OBJECT_ADD;
196
-			if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') {
197
-				$subject = Event::SUBJECT_OBJECT_UPDATE;
198
-			} else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') {
199
-				$subject = Event::SUBJECT_OBJECT_DELETE;
200
-			}
201
-			$backend->onTouchCalendarObject(
202
-				$subject,
203
-				$event->getArgument('calendarData'),
204
-				$event->getArgument('shares'),
205
-				$event->getArgument('objectData')
206
-			);
207
-		};
208
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
209
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
210
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);
211
-	}
212
-
213
-	public function getSyncService() {
214
-		return $this->getContainer()->query(SyncService::class);
215
-	}
64
+        $container->registerCapability(Capabilities::class);
65
+    }
66
+
67
+    /**
68
+     * @param IContactsManager $contactsManager
69
+     * @param string $userID
70
+     */
71
+    public function setupContactsProvider(IContactsManager $contactsManager, $userID) {
72
+        /** @var ContactsManager $cm */
73
+        $cm = $this->getContainer()->query(ContactsManager::class);
74
+        $urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
75
+        $cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
76
+    }
77
+
78
+    /**
79
+     * @param IManager $contactsManager
80
+     */
81
+    public function setupSystemContactsProvider(IContactsManager $contactsManager) {
82
+        /** @var ContactsManager $cm */
83
+        $cm = $this->getContainer()->query(ContactsManager::class);
84
+        $urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
85
+        $cm->setupSystemContactsProvider($contactsManager, $urlGenerator);
86
+    }
87
+
88
+    /**
89
+     * @param ICalendarManager $calendarManager
90
+     * @param string $userId
91
+     */
92
+    public function setupCalendarProvider(ICalendarManager $calendarManager, $userId) {
93
+        $cm = $this->getContainer()->query(CalendarManager::class);
94
+        $cm->setupCalendarProvider($calendarManager, $userId);
95
+    }
96
+
97
+    public function registerHooks() {
98
+        /** @var HookManager $hm */
99
+        $hm = $this->getContainer()->query(HookManager::class);
100
+        $hm->setup();
101
+
102
+        $dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
103
+
104
+        // first time login event setup
105
+        $dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
106
+            if ($event instanceof GenericEvent) {
107
+                $hm->firstLogin($event->getSubject());
108
+            }
109
+        });
110
+
111
+        // carddav/caldav sync event setup
112
+        $listener = function($event) {
113
+            if ($event instanceof GenericEvent) {
114
+                /** @var BirthdayService $b */
115
+                $b = $this->getContainer()->query(BirthdayService::class);
116
+                $b->onCardChanged(
117
+                    $event->getArgument('addressBookId'),
118
+                    $event->getArgument('cardUri'),
119
+                    $event->getArgument('cardData')
120
+                );
121
+            }
122
+        };
123
+
124
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
125
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
126
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
127
+            if ($event instanceof GenericEvent) {
128
+                /** @var BirthdayService $b */
129
+                $b = $this->getContainer()->query(BirthdayService::class);
130
+                $b->onCardDeleted(
131
+                    $event->getArgument('addressBookId'),
132
+                    $event->getArgument('cardUri')
133
+                );
134
+            }
135
+        });
136
+
137
+        $clearPhotoCache = function($event) {
138
+            if ($event instanceof GenericEvent) {
139
+                /** @var PhotoCache $p */
140
+                $p = $this->getContainer()->query(PhotoCache::class);
141
+                $p->delete(
142
+                    $event->getArgument('addressBookId'),
143
+                    $event->getArgument('cardUri')
144
+                );
145
+            }
146
+        };
147
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $clearPhotoCache);
148
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $clearPhotoCache);
149
+
150
+        $dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) {
151
+            $user = $event->getSubject();
152
+            $syncService = $this->getContainer()->query(SyncService::class);
153
+            $syncService->updateUser($user);
154
+        });
155
+
156
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
157
+            /** @var Backend $backend */
158
+            $backend = $this->getContainer()->query(Backend::class);
159
+            $backend->onCalendarAdd(
160
+                $event->getArgument('calendarData')
161
+            );
162
+        });
163
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) {
164
+            /** @var Backend $backend */
165
+            $backend = $this->getContainer()->query(Backend::class);
166
+            $backend->onCalendarUpdate(
167
+                $event->getArgument('calendarData'),
168
+                $event->getArgument('shares'),
169
+                $event->getArgument('propertyMutations')
170
+            );
171
+        });
172
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) {
173
+            /** @var Backend $backend */
174
+            $backend = $this->getContainer()->query(Backend::class);
175
+            $backend->onCalendarDelete(
176
+                $event->getArgument('calendarData'),
177
+                $event->getArgument('shares')
178
+            );
179
+        });
180
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
181
+            /** @var Backend $backend */
182
+            $backend = $this->getContainer()->query(Backend::class);
183
+            $backend->onCalendarUpdateShares(
184
+                $event->getArgument('calendarData'),
185
+                $event->getArgument('shares'),
186
+                $event->getArgument('add'),
187
+                $event->getArgument('remove')
188
+            );
189
+        });
190
+
191
+        $listener = function(GenericEvent $event, $eventName) {
192
+            /** @var Backend $backend */
193
+            $backend = $this->getContainer()->query(Backend::class);
194
+
195
+            $subject = Event::SUBJECT_OBJECT_ADD;
196
+            if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') {
197
+                $subject = Event::SUBJECT_OBJECT_UPDATE;
198
+            } else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') {
199
+                $subject = Event::SUBJECT_OBJECT_DELETE;
200
+            }
201
+            $backend->onTouchCalendarObject(
202
+                $subject,
203
+                $event->getArgument('calendarData'),
204
+                $event->getArgument('shares'),
205
+                $event->getArgument('objectData')
206
+            );
207
+        };
208
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
209
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
210
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);
211
+    }
212
+
213
+    public function getSyncService() {
214
+        return $this->getContainer()->query(SyncService::class);
215
+    }
216 216
 
217 217
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/app.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -31,37 +31,37 @@
 block discarded – undo
31 31
 $app->registerHooks();
32 32
 
33 33
 \OC::$server->registerService('CardDAVSyncService', function() use ($app) {
34
-	return $app->getSyncService();
34
+    return $app->getSyncService();
35 35
 });
36 36
 
37 37
 $eventDispatcher = \OC::$server->getEventDispatcher();
38 38
 
39 39
 $eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove',
40
-	function(GenericEvent $event) use ($app) {
41
-		/** @var CardDavBackend $cardDavBackend */
42
-		$cardDavBackend = $app->getContainer()->query(CardDavBackend::class);
43
-		$addressBookUri = $event->getSubject();
44
-		$addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
45
-		if (!is_null($addressBook)) {
46
-			$cardDavBackend->deleteAddressBook($addressBook['id']);
47
-		}
48
-	}
40
+    function(GenericEvent $event) use ($app) {
41
+        /** @var CardDavBackend $cardDavBackend */
42
+        $cardDavBackend = $app->getContainer()->query(CardDavBackend::class);
43
+        $addressBookUri = $event->getSubject();
44
+        $addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
45
+        if (!is_null($addressBook)) {
46
+            $cardDavBackend->deleteAddressBook($addressBook['id']);
47
+        }
48
+    }
49 49
 );
50 50
 
51 51
 $cm = \OC::$server->getContactsManager();
52 52
 $cm->register(function() use ($cm, $app) {
53
-	$user = \OC::$server->getUserSession()->getUser();
54
-	if (!is_null($user)) {
55
-		$app->setupContactsProvider($cm, $user->getUID());
56
-	} else {
57
-		$app->setupSystemContactsProvider($cm);
58
-	}
53
+    $user = \OC::$server->getUserSession()->getUser();
54
+    if (!is_null($user)) {
55
+        $app->setupContactsProvider($cm, $user->getUID());
56
+    } else {
57
+        $app->setupSystemContactsProvider($cm);
58
+    }
59 59
 });
60 60
 
61 61
 $calendarManager = \OC::$server->getCalendarManager();
62 62
 $calendarManager->register(function() use ($calendarManager, $app) {
63
-	$user = \OC::$server->getUserSession()->getUser();
64
-	if ($user !== null) {
65
-		$app->setupCalendarProvider($calendarManager, $user->getUID());
66
-	}
63
+    $user = \OC::$server->getUserSession()->getUser();
64
+    if ($user !== null) {
65
+        $app->setupCalendarProvider($calendarManager, $user->getUID());
66
+    }
67 67
 });
Please login to merge, or discard this patch.
lib/private/Server.php 1 patch
Indentation   +1744 added lines, -1744 removed lines patch added patch discarded remove patch
@@ -139,1753 +139,1753 @@
 block discarded – undo
139 139
  * TODO: hookup all manager classes
140 140
  */
141 141
 class Server extends ServerContainer implements IServerContainer {
142
-	/** @var string */
143
-	private $webRoot;
144
-
145
-	/**
146
-	 * @param string $webRoot
147
-	 * @param \OC\Config $config
148
-	 */
149
-	public function __construct($webRoot, \OC\Config $config) {
150
-		parent::__construct();
151
-		$this->webRoot = $webRoot;
152
-
153
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
154
-			return $c;
155
-		});
156
-
157
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
158
-		$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
159
-
160
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
161
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
162
-
163
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
164
-
165
-
166
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
167
-			return new PreviewManager(
168
-				$c->getConfig(),
169
-				$c->getRootFolder(),
170
-				$c->getAppDataDir('preview'),
171
-				$c->getEventDispatcher(),
172
-				$c->getSession()->get('user_id')
173
-			);
174
-		});
175
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
176
-
177
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
178
-			return new \OC\Preview\Watcher(
179
-				$c->getAppDataDir('preview')
180
-			);
181
-		});
182
-
183
-		$this->registerService('EncryptionManager', function (Server $c) {
184
-			$view = new View();
185
-			$util = new Encryption\Util(
186
-				$view,
187
-				$c->getUserManager(),
188
-				$c->getGroupManager(),
189
-				$c->getConfig()
190
-			);
191
-			return new Encryption\Manager(
192
-				$c->getConfig(),
193
-				$c->getLogger(),
194
-				$c->getL10N('core'),
195
-				new View(),
196
-				$util,
197
-				new ArrayCache()
198
-			);
199
-		});
200
-
201
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
202
-			$util = new Encryption\Util(
203
-				new View(),
204
-				$c->getUserManager(),
205
-				$c->getGroupManager(),
206
-				$c->getConfig()
207
-			);
208
-			return new Encryption\File(
209
-				$util,
210
-				$c->getRootFolder(),
211
-				$c->getShareManager()
212
-			);
213
-		});
214
-
215
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
216
-			$view = new View();
217
-			$util = new Encryption\Util(
218
-				$view,
219
-				$c->getUserManager(),
220
-				$c->getGroupManager(),
221
-				$c->getConfig()
222
-			);
223
-
224
-			return new Encryption\Keys\Storage($view, $util);
225
-		});
226
-		$this->registerService('TagMapper', function (Server $c) {
227
-			return new TagMapper($c->getDatabaseConnection());
228
-		});
229
-
230
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
231
-			$tagMapper = $c->query('TagMapper');
232
-			return new TagManager($tagMapper, $c->getUserSession());
233
-		});
234
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
235
-
236
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
237
-			$config = $c->getConfig();
238
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
239
-			/** @var \OC\SystemTag\ManagerFactory $factory */
240
-			$factory = new $factoryClass($this);
241
-			return $factory;
242
-		});
243
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
244
-			return $c->query('SystemTagManagerFactory')->getManager();
245
-		});
246
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
247
-
248
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
249
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
250
-		});
251
-		$this->registerService('RootFolder', function (Server $c) {
252
-			$manager = \OC\Files\Filesystem::getMountManager(null);
253
-			$view = new View();
254
-			$root = new Root(
255
-				$manager,
256
-				$view,
257
-				null,
258
-				$c->getUserMountCache(),
259
-				$this->getLogger(),
260
-				$this->getUserManager()
261
-			);
262
-			$connector = new HookConnector($root, $view);
263
-			$connector->viewToNode();
264
-
265
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
266
-			$previewConnector->connectWatcher();
267
-
268
-			return $root;
269
-		});
270
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
271
-
272
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
273
-			return new LazyRoot(function () use ($c) {
274
-				return $c->query('RootFolder');
275
-			});
276
-		});
277
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
278
-
279
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
280
-			$config = $c->getConfig();
281
-			return new \OC\User\Manager($config);
282
-		});
283
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
284
-
285
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
286
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
287
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
288
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
289
-			});
290
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
291
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
292
-			});
293
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
294
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
295
-			});
296
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
297
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
298
-			});
299
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
300
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
301
-			});
302
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
303
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
304
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
305
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
306
-			});
307
-			return $groupManager;
308
-		});
309
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
310
-
311
-		$this->registerService(Store::class, function (Server $c) {
312
-			$session = $c->getSession();
313
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
314
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
315
-			} else {
316
-				$tokenProvider = null;
317
-			}
318
-			$logger = $c->getLogger();
319
-			return new Store($session, $logger, $tokenProvider);
320
-		});
321
-		$this->registerAlias(IStore::class, Store::class);
322
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
323
-			$dbConnection = $c->getDatabaseConnection();
324
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
325
-		});
326
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
327
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
328
-			$crypto = $c->getCrypto();
329
-			$config = $c->getConfig();
330
-			$logger = $c->getLogger();
331
-			$timeFactory = new TimeFactory();
332
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
333
-		});
334
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
335
-
336
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
337
-			$manager = $c->getUserManager();
338
-			$session = new \OC\Session\Memory('');
339
-			$timeFactory = new TimeFactory();
340
-			// Token providers might require a working database. This code
341
-			// might however be called when ownCloud is not yet setup.
342
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
343
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
344
-			} else {
345
-				$defaultTokenProvider = null;
346
-			}
347
-
348
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
349
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
350
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
351
-			});
352
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
353
-				/** @var $user \OC\User\User */
354
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
355
-			});
356
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
357
-				/** @var $user \OC\User\User */
358
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
359
-			});
360
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
361
-				/** @var $user \OC\User\User */
362
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
363
-			});
364
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
365
-				/** @var $user \OC\User\User */
366
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
367
-			});
368
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
369
-				/** @var $user \OC\User\User */
370
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
371
-			});
372
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
373
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
374
-			});
375
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
376
-				/** @var $user \OC\User\User */
377
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
378
-			});
379
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
380
-				/** @var $user \OC\User\User */
381
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
382
-			});
383
-			$userSession->listen('\OC\User', 'logout', function () {
384
-				\OC_Hook::emit('OC_User', 'logout', array());
385
-			});
386
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
387
-				/** @var $user \OC\User\User */
388
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
389
-			});
390
-			return $userSession;
391
-		});
392
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
393
-
394
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
395
-			return new \OC\Authentication\TwoFactorAuth\Manager(
396
-				$c->getAppManager(),
397
-				$c->getSession(),
398
-				$c->getConfig(),
399
-				$c->getActivityManager(),
400
-				$c->getLogger(),
401
-				$c->query(\OC\Authentication\Token\IProvider::class),
402
-				$c->query(ITimeFactory::class)
403
-			);
404
-		});
405
-
406
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
407
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
408
-
409
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
410
-			return new \OC\AllConfig(
411
-				$c->getSystemConfig()
412
-			);
413
-		});
414
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
415
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
416
-
417
-		$this->registerService('SystemConfig', function ($c) use ($config) {
418
-			return new \OC\SystemConfig($config);
419
-		});
420
-
421
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
422
-			return new \OC\AppConfig($c->getDatabaseConnection());
423
-		});
424
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
425
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
426
-
427
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
428
-			return new \OC\L10N\Factory(
429
-				$c->getConfig(),
430
-				$c->getRequest(),
431
-				$c->getUserSession(),
432
-				\OC::$SERVERROOT
433
-			);
434
-		});
435
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
436
-
437
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
438
-			$config = $c->getConfig();
439
-			$cacheFactory = $c->getMemCacheFactory();
440
-			$request = $c->getRequest();
441
-			return new \OC\URLGenerator(
442
-				$config,
443
-				$cacheFactory,
444
-				$request
445
-			);
446
-		});
447
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
448
-
449
-		$this->registerService('AppHelper', function ($c) {
450
-			return new \OC\AppHelper();
451
-		});
452
-		$this->registerAlias('AppFetcher', AppFetcher::class);
453
-		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
454
-
455
-		$this->registerService(\OCP\ICache::class, function ($c) {
456
-			return new Cache\File();
457
-		});
458
-		$this->registerAlias('UserCache', \OCP\ICache::class);
459
-
460
-		$this->registerService(Factory::class, function (Server $c) {
461
-
462
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
463
-				'\\OC\\Memcache\\ArrayCache',
464
-				'\\OC\\Memcache\\ArrayCache',
465
-				'\\OC\\Memcache\\ArrayCache'
466
-			);
467
-			$config = $c->getConfig();
468
-			$request = $c->getRequest();
469
-			$urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
470
-
471
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
472
-				$v = \OC_App::getAppVersions();
473
-				$v['core'] = implode(',', \OC_Util::getVersion());
474
-				$version = implode(',', $v);
475
-				$instanceId = \OC_Util::getInstanceId();
476
-				$path = \OC::$SERVERROOT;
477
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
478
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
479
-					$config->getSystemValue('memcache.local', null),
480
-					$config->getSystemValue('memcache.distributed', null),
481
-					$config->getSystemValue('memcache.locking', null)
482
-				);
483
-			}
484
-			return $arrayCacheFactory;
485
-
486
-		});
487
-		$this->registerAlias('MemCacheFactory', Factory::class);
488
-		$this->registerAlias(ICacheFactory::class, Factory::class);
489
-
490
-		$this->registerService('RedisFactory', function (Server $c) {
491
-			$systemConfig = $c->getSystemConfig();
492
-			return new RedisFactory($systemConfig);
493
-		});
494
-
495
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
496
-			return new \OC\Activity\Manager(
497
-				$c->getRequest(),
498
-				$c->getUserSession(),
499
-				$c->getConfig(),
500
-				$c->query(IValidator::class)
501
-			);
502
-		});
503
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
504
-
505
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
506
-			return new \OC\Activity\EventMerger(
507
-				$c->getL10N('lib')
508
-			);
509
-		});
510
-		$this->registerAlias(IValidator::class, Validator::class);
511
-
512
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
513
-			return new AvatarManager(
514
-				$c->getUserManager(),
515
-				$c->getAppDataDir('avatar'),
516
-				$c->getL10N('lib'),
517
-				$c->getLogger(),
518
-				$c->getConfig()
519
-			);
520
-		});
521
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
522
-
523
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
524
-
525
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
526
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
527
-			$logger = Log::getLogClass($logType);
528
-			call_user_func(array($logger, 'init'));
529
-			$config = $this->getSystemConfig();
530
-			$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
531
-
532
-			return new Log($logger, $config, null, $registry);
533
-		});
534
-		$this->registerAlias('Logger', \OCP\ILogger::class);
535
-
536
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
537
-			$config = $c->getConfig();
538
-			return new \OC\BackgroundJob\JobList(
539
-				$c->getDatabaseConnection(),
540
-				$config,
541
-				new TimeFactory()
542
-			);
543
-		});
544
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
545
-
546
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
547
-			$cacheFactory = $c->getMemCacheFactory();
548
-			$logger = $c->getLogger();
549
-			if ($cacheFactory->isAvailableLowLatency()) {
550
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
551
-			} else {
552
-				$router = new \OC\Route\Router($logger);
553
-			}
554
-			return $router;
555
-		});
556
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
557
-
558
-		$this->registerService(\OCP\ISearch::class, function ($c) {
559
-			return new Search();
560
-		});
561
-		$this->registerAlias('Search', \OCP\ISearch::class);
562
-
563
-		$this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
564
-			return new \OC\Security\RateLimiting\Limiter(
565
-				$this->getUserSession(),
566
-				$this->getRequest(),
567
-				new \OC\AppFramework\Utility\TimeFactory(),
568
-				$c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
569
-			);
570
-		});
571
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
572
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
573
-				$this->getMemCacheFactory(),
574
-				new \OC\AppFramework\Utility\TimeFactory()
575
-			);
576
-		});
577
-
578
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
579
-			return new SecureRandom();
580
-		});
581
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
582
-
583
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
584
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
585
-		});
586
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
587
-
588
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
589
-			return new Hasher($c->getConfig());
590
-		});
591
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
592
-
593
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
594
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
595
-		});
596
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
597
-
598
-		$this->registerService(IDBConnection::class, function (Server $c) {
599
-			$systemConfig = $c->getSystemConfig();
600
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
601
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
602
-			if (!$factory->isValidType($type)) {
603
-				throw new \OC\DatabaseException('Invalid database type');
604
-			}
605
-			$connectionParams = $factory->createConnectionParams();
606
-			$connection = $factory->getConnection($type, $connectionParams);
607
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
608
-			return $connection;
609
-		});
610
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
611
-
612
-		$this->registerService('HTTPHelper', function (Server $c) {
613
-			$config = $c->getConfig();
614
-			return new HTTPHelper(
615
-				$config,
616
-				$c->getHTTPClientService()
617
-			);
618
-		});
619
-
620
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
621
-			$user = \OC_User::getUser();
622
-			$uid = $user ? $user : null;
623
-			return new ClientService(
624
-				$c->getConfig(),
625
-				new \OC\Security\CertificateManager(
626
-					$uid,
627
-					new View(),
628
-					$c->getConfig(),
629
-					$c->getLogger(),
630
-					$c->getSecureRandom()
631
-				)
632
-			);
633
-		});
634
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
635
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
636
-			$eventLogger = new EventLogger();
637
-			if ($c->getSystemConfig()->getValue('debug', false)) {
638
-				// In debug mode, module is being activated by default
639
-				$eventLogger->activate();
640
-			}
641
-			return $eventLogger;
642
-		});
643
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
644
-
645
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
646
-			$queryLogger = new QueryLogger();
647
-			if ($c->getSystemConfig()->getValue('debug', false)) {
648
-				// In debug mode, module is being activated by default
649
-				$queryLogger->activate();
650
-			}
651
-			return $queryLogger;
652
-		});
653
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
654
-
655
-		$this->registerService(TempManager::class, function (Server $c) {
656
-			return new TempManager(
657
-				$c->getLogger(),
658
-				$c->getConfig()
659
-			);
660
-		});
661
-		$this->registerAlias('TempManager', TempManager::class);
662
-		$this->registerAlias(ITempManager::class, TempManager::class);
663
-
664
-		$this->registerService(AppManager::class, function (Server $c) {
665
-			return new \OC\App\AppManager(
666
-				$c->getUserSession(),
667
-				$c->getAppConfig(),
668
-				$c->getGroupManager(),
669
-				$c->getMemCacheFactory(),
670
-				$c->getEventDispatcher()
671
-			);
672
-		});
673
-		$this->registerAlias('AppManager', AppManager::class);
674
-		$this->registerAlias(IAppManager::class, AppManager::class);
675
-
676
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
677
-			return new DateTimeZone(
678
-				$c->getConfig(),
679
-				$c->getSession()
680
-			);
681
-		});
682
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
683
-
684
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
685
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
686
-
687
-			return new DateTimeFormatter(
688
-				$c->getDateTimeZone()->getTimeZone(),
689
-				$c->getL10N('lib', $language)
690
-			);
691
-		});
692
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
693
-
694
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
695
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
696
-			$listener = new UserMountCacheListener($mountCache);
697
-			$listener->listen($c->getUserManager());
698
-			return $mountCache;
699
-		});
700
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
701
-
702
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
703
-			$loader = \OC\Files\Filesystem::getLoader();
704
-			$mountCache = $c->query('UserMountCache');
705
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
706
-
707
-			// builtin providers
708
-
709
-			$config = $c->getConfig();
710
-			$manager->registerProvider(new CacheMountProvider($config));
711
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
712
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
713
-
714
-			return $manager;
715
-		});
716
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
717
-
718
-		$this->registerService('IniWrapper', function ($c) {
719
-			return new IniGetWrapper();
720
-		});
721
-		$this->registerService('AsyncCommandBus', function (Server $c) {
722
-			$busClass = $c->getConfig()->getSystemValue('commandbus');
723
-			if ($busClass) {
724
-				list($app, $class) = explode('::', $busClass, 2);
725
-				if ($c->getAppManager()->isInstalled($app)) {
726
-					\OC_App::loadApp($app);
727
-					return $c->query($class);
728
-				} else {
729
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
730
-				}
731
-			} else {
732
-				$jobList = $c->getJobList();
733
-				return new CronBus($jobList);
734
-			}
735
-		});
736
-		$this->registerService('TrustedDomainHelper', function ($c) {
737
-			return new TrustedDomainHelper($this->getConfig());
738
-		});
739
-		$this->registerService('Throttler', function (Server $c) {
740
-			return new Throttler(
741
-				$c->getDatabaseConnection(),
742
-				new TimeFactory(),
743
-				$c->getLogger(),
744
-				$c->getConfig()
745
-			);
746
-		});
747
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
748
-			// IConfig and IAppManager requires a working database. This code
749
-			// might however be called when ownCloud is not yet setup.
750
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
751
-				$config = $c->getConfig();
752
-				$appManager = $c->getAppManager();
753
-			} else {
754
-				$config = null;
755
-				$appManager = null;
756
-			}
757
-
758
-			return new Checker(
759
-				new EnvironmentHelper(),
760
-				new FileAccessHelper(),
761
-				new AppLocator(),
762
-				$config,
763
-				$c->getMemCacheFactory(),
764
-				$appManager,
765
-				$c->getTempManager()
766
-			);
767
-		});
768
-		$this->registerService(\OCP\IRequest::class, function ($c) {
769
-			if (isset($this['urlParams'])) {
770
-				$urlParams = $this['urlParams'];
771
-			} else {
772
-				$urlParams = [];
773
-			}
774
-
775
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
776
-				&& in_array('fakeinput', stream_get_wrappers())
777
-			) {
778
-				$stream = 'fakeinput://data';
779
-			} else {
780
-				$stream = 'php://input';
781
-			}
782
-
783
-			return new Request(
784
-				[
785
-					'get' => $_GET,
786
-					'post' => $_POST,
787
-					'files' => $_FILES,
788
-					'server' => $_SERVER,
789
-					'env' => $_ENV,
790
-					'cookies' => $_COOKIE,
791
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
792
-						? $_SERVER['REQUEST_METHOD']
793
-						: null,
794
-					'urlParams' => $urlParams,
795
-				],
796
-				$this->getSecureRandom(),
797
-				$this->getConfig(),
798
-				$this->getCsrfTokenManager(),
799
-				$stream
800
-			);
801
-		});
802
-		$this->registerAlias('Request', \OCP\IRequest::class);
803
-
804
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
805
-			return new Mailer(
806
-				$c->getConfig(),
807
-				$c->getLogger(),
808
-				$c->query(Defaults::class),
809
-				$c->getURLGenerator(),
810
-				$c->getL10N('lib')
811
-			);
812
-		});
813
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
814
-
815
-		$this->registerService('LDAPProvider', function (Server $c) {
816
-			$config = $c->getConfig();
817
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
818
-			if (is_null($factoryClass)) {
819
-				throw new \Exception('ldapProviderFactory not set');
820
-			}
821
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
822
-			$factory = new $factoryClass($this);
823
-			return $factory->getLDAPProvider();
824
-		});
825
-		$this->registerService(ILockingProvider::class, function (Server $c) {
826
-			$ini = $c->getIniWrapper();
827
-			$config = $c->getConfig();
828
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
829
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
830
-				/** @var \OC\Memcache\Factory $memcacheFactory */
831
-				$memcacheFactory = $c->getMemCacheFactory();
832
-				$memcache = $memcacheFactory->createLocking('lock');
833
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
834
-					return new MemcacheLockingProvider($memcache, $ttl);
835
-				}
836
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
837
-			}
838
-			return new NoopLockingProvider();
839
-		});
840
-		$this->registerAlias('LockingProvider', ILockingProvider::class);
841
-
842
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
843
-			return new \OC\Files\Mount\Manager();
844
-		});
845
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
846
-
847
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
848
-			return new \OC\Files\Type\Detection(
849
-				$c->getURLGenerator(),
850
-				\OC::$configDir,
851
-				\OC::$SERVERROOT . '/resources/config/'
852
-			);
853
-		});
854
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
855
-
856
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
857
-			return new \OC\Files\Type\Loader(
858
-				$c->getDatabaseConnection()
859
-			);
860
-		});
861
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
862
-		$this->registerService(BundleFetcher::class, function () {
863
-			return new BundleFetcher($this->getL10N('lib'));
864
-		});
865
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
866
-			return new Manager(
867
-				$c->query(IValidator::class)
868
-			);
869
-		});
870
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
871
-
872
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
873
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
874
-			$manager->registerCapability(function () use ($c) {
875
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
876
-			});
877
-			$manager->registerCapability(function () use ($c) {
878
-				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
879
-			});
880
-			return $manager;
881
-		});
882
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
883
-
884
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
885
-			$config = $c->getConfig();
886
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
887
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
888
-			$factory = new $factoryClass($this);
889
-			return $factory->getManager();
890
-		});
891
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
892
-
893
-		$this->registerService('ThemingDefaults', function (Server $c) {
894
-			/*
142
+    /** @var string */
143
+    private $webRoot;
144
+
145
+    /**
146
+     * @param string $webRoot
147
+     * @param \OC\Config $config
148
+     */
149
+    public function __construct($webRoot, \OC\Config $config) {
150
+        parent::__construct();
151
+        $this->webRoot = $webRoot;
152
+
153
+        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
154
+            return $c;
155
+        });
156
+
157
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
158
+        $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
159
+
160
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
161
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
162
+
163
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
164
+
165
+
166
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
167
+            return new PreviewManager(
168
+                $c->getConfig(),
169
+                $c->getRootFolder(),
170
+                $c->getAppDataDir('preview'),
171
+                $c->getEventDispatcher(),
172
+                $c->getSession()->get('user_id')
173
+            );
174
+        });
175
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
176
+
177
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
178
+            return new \OC\Preview\Watcher(
179
+                $c->getAppDataDir('preview')
180
+            );
181
+        });
182
+
183
+        $this->registerService('EncryptionManager', function (Server $c) {
184
+            $view = new View();
185
+            $util = new Encryption\Util(
186
+                $view,
187
+                $c->getUserManager(),
188
+                $c->getGroupManager(),
189
+                $c->getConfig()
190
+            );
191
+            return new Encryption\Manager(
192
+                $c->getConfig(),
193
+                $c->getLogger(),
194
+                $c->getL10N('core'),
195
+                new View(),
196
+                $util,
197
+                new ArrayCache()
198
+            );
199
+        });
200
+
201
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
202
+            $util = new Encryption\Util(
203
+                new View(),
204
+                $c->getUserManager(),
205
+                $c->getGroupManager(),
206
+                $c->getConfig()
207
+            );
208
+            return new Encryption\File(
209
+                $util,
210
+                $c->getRootFolder(),
211
+                $c->getShareManager()
212
+            );
213
+        });
214
+
215
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
216
+            $view = new View();
217
+            $util = new Encryption\Util(
218
+                $view,
219
+                $c->getUserManager(),
220
+                $c->getGroupManager(),
221
+                $c->getConfig()
222
+            );
223
+
224
+            return new Encryption\Keys\Storage($view, $util);
225
+        });
226
+        $this->registerService('TagMapper', function (Server $c) {
227
+            return new TagMapper($c->getDatabaseConnection());
228
+        });
229
+
230
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
231
+            $tagMapper = $c->query('TagMapper');
232
+            return new TagManager($tagMapper, $c->getUserSession());
233
+        });
234
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
235
+
236
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
237
+            $config = $c->getConfig();
238
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
239
+            /** @var \OC\SystemTag\ManagerFactory $factory */
240
+            $factory = new $factoryClass($this);
241
+            return $factory;
242
+        });
243
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
244
+            return $c->query('SystemTagManagerFactory')->getManager();
245
+        });
246
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
247
+
248
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
249
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
250
+        });
251
+        $this->registerService('RootFolder', function (Server $c) {
252
+            $manager = \OC\Files\Filesystem::getMountManager(null);
253
+            $view = new View();
254
+            $root = new Root(
255
+                $manager,
256
+                $view,
257
+                null,
258
+                $c->getUserMountCache(),
259
+                $this->getLogger(),
260
+                $this->getUserManager()
261
+            );
262
+            $connector = new HookConnector($root, $view);
263
+            $connector->viewToNode();
264
+
265
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
266
+            $previewConnector->connectWatcher();
267
+
268
+            return $root;
269
+        });
270
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
271
+
272
+        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
273
+            return new LazyRoot(function () use ($c) {
274
+                return $c->query('RootFolder');
275
+            });
276
+        });
277
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
278
+
279
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
280
+            $config = $c->getConfig();
281
+            return new \OC\User\Manager($config);
282
+        });
283
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
284
+
285
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
286
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
287
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
288
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
289
+            });
290
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
291
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
292
+            });
293
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
294
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
295
+            });
296
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
297
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
298
+            });
299
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
300
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
301
+            });
302
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
303
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
304
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
305
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
306
+            });
307
+            return $groupManager;
308
+        });
309
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
310
+
311
+        $this->registerService(Store::class, function (Server $c) {
312
+            $session = $c->getSession();
313
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
314
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
315
+            } else {
316
+                $tokenProvider = null;
317
+            }
318
+            $logger = $c->getLogger();
319
+            return new Store($session, $logger, $tokenProvider);
320
+        });
321
+        $this->registerAlias(IStore::class, Store::class);
322
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
323
+            $dbConnection = $c->getDatabaseConnection();
324
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
325
+        });
326
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
327
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
328
+            $crypto = $c->getCrypto();
329
+            $config = $c->getConfig();
330
+            $logger = $c->getLogger();
331
+            $timeFactory = new TimeFactory();
332
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
333
+        });
334
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
335
+
336
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
337
+            $manager = $c->getUserManager();
338
+            $session = new \OC\Session\Memory('');
339
+            $timeFactory = new TimeFactory();
340
+            // Token providers might require a working database. This code
341
+            // might however be called when ownCloud is not yet setup.
342
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
343
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
344
+            } else {
345
+                $defaultTokenProvider = null;
346
+            }
347
+
348
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager());
349
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
350
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
351
+            });
352
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
353
+                /** @var $user \OC\User\User */
354
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
355
+            });
356
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
357
+                /** @var $user \OC\User\User */
358
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
359
+            });
360
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
361
+                /** @var $user \OC\User\User */
362
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
363
+            });
364
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
365
+                /** @var $user \OC\User\User */
366
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
367
+            });
368
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
369
+                /** @var $user \OC\User\User */
370
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
371
+            });
372
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
373
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
374
+            });
375
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
376
+                /** @var $user \OC\User\User */
377
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
378
+            });
379
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
380
+                /** @var $user \OC\User\User */
381
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
382
+            });
383
+            $userSession->listen('\OC\User', 'logout', function () {
384
+                \OC_Hook::emit('OC_User', 'logout', array());
385
+            });
386
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
387
+                /** @var $user \OC\User\User */
388
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
389
+            });
390
+            return $userSession;
391
+        });
392
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
393
+
394
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
395
+            return new \OC\Authentication\TwoFactorAuth\Manager(
396
+                $c->getAppManager(),
397
+                $c->getSession(),
398
+                $c->getConfig(),
399
+                $c->getActivityManager(),
400
+                $c->getLogger(),
401
+                $c->query(\OC\Authentication\Token\IProvider::class),
402
+                $c->query(ITimeFactory::class)
403
+            );
404
+        });
405
+
406
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
407
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
408
+
409
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
410
+            return new \OC\AllConfig(
411
+                $c->getSystemConfig()
412
+            );
413
+        });
414
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
415
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
416
+
417
+        $this->registerService('SystemConfig', function ($c) use ($config) {
418
+            return new \OC\SystemConfig($config);
419
+        });
420
+
421
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
422
+            return new \OC\AppConfig($c->getDatabaseConnection());
423
+        });
424
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
425
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
426
+
427
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
428
+            return new \OC\L10N\Factory(
429
+                $c->getConfig(),
430
+                $c->getRequest(),
431
+                $c->getUserSession(),
432
+                \OC::$SERVERROOT
433
+            );
434
+        });
435
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
436
+
437
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
438
+            $config = $c->getConfig();
439
+            $cacheFactory = $c->getMemCacheFactory();
440
+            $request = $c->getRequest();
441
+            return new \OC\URLGenerator(
442
+                $config,
443
+                $cacheFactory,
444
+                $request
445
+            );
446
+        });
447
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
448
+
449
+        $this->registerService('AppHelper', function ($c) {
450
+            return new \OC\AppHelper();
451
+        });
452
+        $this->registerAlias('AppFetcher', AppFetcher::class);
453
+        $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
454
+
455
+        $this->registerService(\OCP\ICache::class, function ($c) {
456
+            return new Cache\File();
457
+        });
458
+        $this->registerAlias('UserCache', \OCP\ICache::class);
459
+
460
+        $this->registerService(Factory::class, function (Server $c) {
461
+
462
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
463
+                '\\OC\\Memcache\\ArrayCache',
464
+                '\\OC\\Memcache\\ArrayCache',
465
+                '\\OC\\Memcache\\ArrayCache'
466
+            );
467
+            $config = $c->getConfig();
468
+            $request = $c->getRequest();
469
+            $urlGenerator = new URLGenerator($config, $arrayCacheFactory, $request);
470
+
471
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
472
+                $v = \OC_App::getAppVersions();
473
+                $v['core'] = implode(',', \OC_Util::getVersion());
474
+                $version = implode(',', $v);
475
+                $instanceId = \OC_Util::getInstanceId();
476
+                $path = \OC::$SERVERROOT;
477
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . $urlGenerator->getBaseUrl());
478
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
479
+                    $config->getSystemValue('memcache.local', null),
480
+                    $config->getSystemValue('memcache.distributed', null),
481
+                    $config->getSystemValue('memcache.locking', null)
482
+                );
483
+            }
484
+            return $arrayCacheFactory;
485
+
486
+        });
487
+        $this->registerAlias('MemCacheFactory', Factory::class);
488
+        $this->registerAlias(ICacheFactory::class, Factory::class);
489
+
490
+        $this->registerService('RedisFactory', function (Server $c) {
491
+            $systemConfig = $c->getSystemConfig();
492
+            return new RedisFactory($systemConfig);
493
+        });
494
+
495
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
496
+            return new \OC\Activity\Manager(
497
+                $c->getRequest(),
498
+                $c->getUserSession(),
499
+                $c->getConfig(),
500
+                $c->query(IValidator::class)
501
+            );
502
+        });
503
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
504
+
505
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
506
+            return new \OC\Activity\EventMerger(
507
+                $c->getL10N('lib')
508
+            );
509
+        });
510
+        $this->registerAlias(IValidator::class, Validator::class);
511
+
512
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
513
+            return new AvatarManager(
514
+                $c->getUserManager(),
515
+                $c->getAppDataDir('avatar'),
516
+                $c->getL10N('lib'),
517
+                $c->getLogger(),
518
+                $c->getConfig()
519
+            );
520
+        });
521
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
522
+
523
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
524
+
525
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
526
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
527
+            $logger = Log::getLogClass($logType);
528
+            call_user_func(array($logger, 'init'));
529
+            $config = $this->getSystemConfig();
530
+            $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
531
+
532
+            return new Log($logger, $config, null, $registry);
533
+        });
534
+        $this->registerAlias('Logger', \OCP\ILogger::class);
535
+
536
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
537
+            $config = $c->getConfig();
538
+            return new \OC\BackgroundJob\JobList(
539
+                $c->getDatabaseConnection(),
540
+                $config,
541
+                new TimeFactory()
542
+            );
543
+        });
544
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
545
+
546
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
547
+            $cacheFactory = $c->getMemCacheFactory();
548
+            $logger = $c->getLogger();
549
+            if ($cacheFactory->isAvailableLowLatency()) {
550
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
551
+            } else {
552
+                $router = new \OC\Route\Router($logger);
553
+            }
554
+            return $router;
555
+        });
556
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
557
+
558
+        $this->registerService(\OCP\ISearch::class, function ($c) {
559
+            return new Search();
560
+        });
561
+        $this->registerAlias('Search', \OCP\ISearch::class);
562
+
563
+        $this->registerService(\OC\Security\RateLimiting\Limiter::class, function ($c) {
564
+            return new \OC\Security\RateLimiting\Limiter(
565
+                $this->getUserSession(),
566
+                $this->getRequest(),
567
+                new \OC\AppFramework\Utility\TimeFactory(),
568
+                $c->query(\OC\Security\RateLimiting\Backend\IBackend::class)
569
+            );
570
+        });
571
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
572
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
573
+                $this->getMemCacheFactory(),
574
+                new \OC\AppFramework\Utility\TimeFactory()
575
+            );
576
+        });
577
+
578
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
579
+            return new SecureRandom();
580
+        });
581
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
582
+
583
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
584
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
585
+        });
586
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
587
+
588
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
589
+            return new Hasher($c->getConfig());
590
+        });
591
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
592
+
593
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
594
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
595
+        });
596
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
597
+
598
+        $this->registerService(IDBConnection::class, function (Server $c) {
599
+            $systemConfig = $c->getSystemConfig();
600
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
601
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
602
+            if (!$factory->isValidType($type)) {
603
+                throw new \OC\DatabaseException('Invalid database type');
604
+            }
605
+            $connectionParams = $factory->createConnectionParams();
606
+            $connection = $factory->getConnection($type, $connectionParams);
607
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
608
+            return $connection;
609
+        });
610
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
611
+
612
+        $this->registerService('HTTPHelper', function (Server $c) {
613
+            $config = $c->getConfig();
614
+            return new HTTPHelper(
615
+                $config,
616
+                $c->getHTTPClientService()
617
+            );
618
+        });
619
+
620
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
621
+            $user = \OC_User::getUser();
622
+            $uid = $user ? $user : null;
623
+            return new ClientService(
624
+                $c->getConfig(),
625
+                new \OC\Security\CertificateManager(
626
+                    $uid,
627
+                    new View(),
628
+                    $c->getConfig(),
629
+                    $c->getLogger(),
630
+                    $c->getSecureRandom()
631
+                )
632
+            );
633
+        });
634
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
635
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
636
+            $eventLogger = new EventLogger();
637
+            if ($c->getSystemConfig()->getValue('debug', false)) {
638
+                // In debug mode, module is being activated by default
639
+                $eventLogger->activate();
640
+            }
641
+            return $eventLogger;
642
+        });
643
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
644
+
645
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
646
+            $queryLogger = new QueryLogger();
647
+            if ($c->getSystemConfig()->getValue('debug', false)) {
648
+                // In debug mode, module is being activated by default
649
+                $queryLogger->activate();
650
+            }
651
+            return $queryLogger;
652
+        });
653
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
654
+
655
+        $this->registerService(TempManager::class, function (Server $c) {
656
+            return new TempManager(
657
+                $c->getLogger(),
658
+                $c->getConfig()
659
+            );
660
+        });
661
+        $this->registerAlias('TempManager', TempManager::class);
662
+        $this->registerAlias(ITempManager::class, TempManager::class);
663
+
664
+        $this->registerService(AppManager::class, function (Server $c) {
665
+            return new \OC\App\AppManager(
666
+                $c->getUserSession(),
667
+                $c->getAppConfig(),
668
+                $c->getGroupManager(),
669
+                $c->getMemCacheFactory(),
670
+                $c->getEventDispatcher()
671
+            );
672
+        });
673
+        $this->registerAlias('AppManager', AppManager::class);
674
+        $this->registerAlias(IAppManager::class, AppManager::class);
675
+
676
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
677
+            return new DateTimeZone(
678
+                $c->getConfig(),
679
+                $c->getSession()
680
+            );
681
+        });
682
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
683
+
684
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
685
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
686
+
687
+            return new DateTimeFormatter(
688
+                $c->getDateTimeZone()->getTimeZone(),
689
+                $c->getL10N('lib', $language)
690
+            );
691
+        });
692
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
693
+
694
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
695
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
696
+            $listener = new UserMountCacheListener($mountCache);
697
+            $listener->listen($c->getUserManager());
698
+            return $mountCache;
699
+        });
700
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
701
+
702
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
703
+            $loader = \OC\Files\Filesystem::getLoader();
704
+            $mountCache = $c->query('UserMountCache');
705
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
706
+
707
+            // builtin providers
708
+
709
+            $config = $c->getConfig();
710
+            $manager->registerProvider(new CacheMountProvider($config));
711
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
712
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
713
+
714
+            return $manager;
715
+        });
716
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
717
+
718
+        $this->registerService('IniWrapper', function ($c) {
719
+            return new IniGetWrapper();
720
+        });
721
+        $this->registerService('AsyncCommandBus', function (Server $c) {
722
+            $busClass = $c->getConfig()->getSystemValue('commandbus');
723
+            if ($busClass) {
724
+                list($app, $class) = explode('::', $busClass, 2);
725
+                if ($c->getAppManager()->isInstalled($app)) {
726
+                    \OC_App::loadApp($app);
727
+                    return $c->query($class);
728
+                } else {
729
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
730
+                }
731
+            } else {
732
+                $jobList = $c->getJobList();
733
+                return new CronBus($jobList);
734
+            }
735
+        });
736
+        $this->registerService('TrustedDomainHelper', function ($c) {
737
+            return new TrustedDomainHelper($this->getConfig());
738
+        });
739
+        $this->registerService('Throttler', function (Server $c) {
740
+            return new Throttler(
741
+                $c->getDatabaseConnection(),
742
+                new TimeFactory(),
743
+                $c->getLogger(),
744
+                $c->getConfig()
745
+            );
746
+        });
747
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
748
+            // IConfig and IAppManager requires a working database. This code
749
+            // might however be called when ownCloud is not yet setup.
750
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
751
+                $config = $c->getConfig();
752
+                $appManager = $c->getAppManager();
753
+            } else {
754
+                $config = null;
755
+                $appManager = null;
756
+            }
757
+
758
+            return new Checker(
759
+                new EnvironmentHelper(),
760
+                new FileAccessHelper(),
761
+                new AppLocator(),
762
+                $config,
763
+                $c->getMemCacheFactory(),
764
+                $appManager,
765
+                $c->getTempManager()
766
+            );
767
+        });
768
+        $this->registerService(\OCP\IRequest::class, function ($c) {
769
+            if (isset($this['urlParams'])) {
770
+                $urlParams = $this['urlParams'];
771
+            } else {
772
+                $urlParams = [];
773
+            }
774
+
775
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
776
+                && in_array('fakeinput', stream_get_wrappers())
777
+            ) {
778
+                $stream = 'fakeinput://data';
779
+            } else {
780
+                $stream = 'php://input';
781
+            }
782
+
783
+            return new Request(
784
+                [
785
+                    'get' => $_GET,
786
+                    'post' => $_POST,
787
+                    'files' => $_FILES,
788
+                    'server' => $_SERVER,
789
+                    'env' => $_ENV,
790
+                    'cookies' => $_COOKIE,
791
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
792
+                        ? $_SERVER['REQUEST_METHOD']
793
+                        : null,
794
+                    'urlParams' => $urlParams,
795
+                ],
796
+                $this->getSecureRandom(),
797
+                $this->getConfig(),
798
+                $this->getCsrfTokenManager(),
799
+                $stream
800
+            );
801
+        });
802
+        $this->registerAlias('Request', \OCP\IRequest::class);
803
+
804
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
805
+            return new Mailer(
806
+                $c->getConfig(),
807
+                $c->getLogger(),
808
+                $c->query(Defaults::class),
809
+                $c->getURLGenerator(),
810
+                $c->getL10N('lib')
811
+            );
812
+        });
813
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
814
+
815
+        $this->registerService('LDAPProvider', function (Server $c) {
816
+            $config = $c->getConfig();
817
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
818
+            if (is_null($factoryClass)) {
819
+                throw new \Exception('ldapProviderFactory not set');
820
+            }
821
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
822
+            $factory = new $factoryClass($this);
823
+            return $factory->getLDAPProvider();
824
+        });
825
+        $this->registerService(ILockingProvider::class, function (Server $c) {
826
+            $ini = $c->getIniWrapper();
827
+            $config = $c->getConfig();
828
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
829
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
830
+                /** @var \OC\Memcache\Factory $memcacheFactory */
831
+                $memcacheFactory = $c->getMemCacheFactory();
832
+                $memcache = $memcacheFactory->createLocking('lock');
833
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
834
+                    return new MemcacheLockingProvider($memcache, $ttl);
835
+                }
836
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
837
+            }
838
+            return new NoopLockingProvider();
839
+        });
840
+        $this->registerAlias('LockingProvider', ILockingProvider::class);
841
+
842
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
843
+            return new \OC\Files\Mount\Manager();
844
+        });
845
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
846
+
847
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
848
+            return new \OC\Files\Type\Detection(
849
+                $c->getURLGenerator(),
850
+                \OC::$configDir,
851
+                \OC::$SERVERROOT . '/resources/config/'
852
+            );
853
+        });
854
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
855
+
856
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
857
+            return new \OC\Files\Type\Loader(
858
+                $c->getDatabaseConnection()
859
+            );
860
+        });
861
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
862
+        $this->registerService(BundleFetcher::class, function () {
863
+            return new BundleFetcher($this->getL10N('lib'));
864
+        });
865
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
866
+            return new Manager(
867
+                $c->query(IValidator::class)
868
+            );
869
+        });
870
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
871
+
872
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
873
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
874
+            $manager->registerCapability(function () use ($c) {
875
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
876
+            });
877
+            $manager->registerCapability(function () use ($c) {
878
+                return $c->query(\OC\Security\Bruteforce\Capabilities::class);
879
+            });
880
+            return $manager;
881
+        });
882
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
883
+
884
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
885
+            $config = $c->getConfig();
886
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
887
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
888
+            $factory = new $factoryClass($this);
889
+            return $factory->getManager();
890
+        });
891
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
892
+
893
+        $this->registerService('ThemingDefaults', function (Server $c) {
894
+            /*
895 895
 			 * Dark magic for autoloader.
896 896
 			 * If we do a class_exists it will try to load the class which will
897 897
 			 * make composer cache the result. Resulting in errors when enabling
898 898
 			 * the theming app.
899 899
 			 */
900
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
901
-			if (isset($prefixes['OCA\\Theming\\'])) {
902
-				$classExists = true;
903
-			} else {
904
-				$classExists = false;
905
-			}
906
-
907
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
908
-				return new ThemingDefaults(
909
-					$c->getConfig(),
910
-					$c->getL10N('theming'),
911
-					$c->getURLGenerator(),
912
-					$c->getAppDataDir('theming'),
913
-					$c->getMemCacheFactory(),
914
-					new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')),
915
-					$this->getAppManager()
916
-				);
917
-			}
918
-			return new \OC_Defaults();
919
-		});
920
-		$this->registerService(SCSSCacher::class, function (Server $c) {
921
-			/** @var Factory $cacheFactory */
922
-			$cacheFactory = $c->query(Factory::class);
923
-			return new SCSSCacher(
924
-				$c->getLogger(),
925
-				$c->query(\OC\Files\AppData\Factory::class),
926
-				$c->getURLGenerator(),
927
-				$c->getConfig(),
928
-				$c->getThemingDefaults(),
929
-				\OC::$SERVERROOT,
930
-				$cacheFactory->create('SCSS')
931
-			);
932
-		});
933
-		$this->registerService(EventDispatcher::class, function () {
934
-			return new EventDispatcher();
935
-		});
936
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
937
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
938
-
939
-		$this->registerService('CryptoWrapper', function (Server $c) {
940
-			// FIXME: Instantiiated here due to cyclic dependency
941
-			$request = new Request(
942
-				[
943
-					'get' => $_GET,
944
-					'post' => $_POST,
945
-					'files' => $_FILES,
946
-					'server' => $_SERVER,
947
-					'env' => $_ENV,
948
-					'cookies' => $_COOKIE,
949
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
950
-						? $_SERVER['REQUEST_METHOD']
951
-						: null,
952
-				],
953
-				$c->getSecureRandom(),
954
-				$c->getConfig()
955
-			);
956
-
957
-			return new CryptoWrapper(
958
-				$c->getConfig(),
959
-				$c->getCrypto(),
960
-				$c->getSecureRandom(),
961
-				$request
962
-			);
963
-		});
964
-		$this->registerService('CsrfTokenManager', function (Server $c) {
965
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
966
-
967
-			return new CsrfTokenManager(
968
-				$tokenGenerator,
969
-				$c->query(SessionStorage::class)
970
-			);
971
-		});
972
-		$this->registerService(SessionStorage::class, function (Server $c) {
973
-			return new SessionStorage($c->getSession());
974
-		});
975
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
976
-			return new ContentSecurityPolicyManager();
977
-		});
978
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
979
-
980
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
981
-			return new ContentSecurityPolicyNonceManager(
982
-				$c->getCsrfTokenManager(),
983
-				$c->getRequest()
984
-			);
985
-		});
986
-
987
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
988
-			$config = $c->getConfig();
989
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
990
-			/** @var \OCP\Share\IProviderFactory $factory */
991
-			$factory = new $factoryClass($this);
992
-
993
-			$manager = new \OC\Share20\Manager(
994
-				$c->getLogger(),
995
-				$c->getConfig(),
996
-				$c->getSecureRandom(),
997
-				$c->getHasher(),
998
-				$c->getMountManager(),
999
-				$c->getGroupManager(),
1000
-				$c->getL10N('lib'),
1001
-				$c->getL10NFactory(),
1002
-				$factory,
1003
-				$c->getUserManager(),
1004
-				$c->getLazyRootFolder(),
1005
-				$c->getEventDispatcher(),
1006
-				$c->getMailer(),
1007
-				$c->getURLGenerator(),
1008
-				$c->getThemingDefaults()
1009
-			);
1010
-
1011
-			return $manager;
1012
-		});
1013
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1014
-
1015
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1016
-			$instance = new Collaboration\Collaborators\Search($c);
1017
-
1018
-			// register default plugins
1019
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1020
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1021
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1022
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1023
-
1024
-			return $instance;
1025
-		});
1026
-		$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1027
-
1028
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1029
-
1030
-		$this->registerService('SettingsManager', function (Server $c) {
1031
-			$manager = new \OC\Settings\Manager(
1032
-				$c->getLogger(),
1033
-				$c->getDatabaseConnection(),
1034
-				$c->getL10N('lib'),
1035
-				$c->getConfig(),
1036
-				$c->getEncryptionManager(),
1037
-				$c->getUserManager(),
1038
-				$c->getLockingProvider(),
1039
-				$c->getRequest(),
1040
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
1041
-				$c->getURLGenerator(),
1042
-				$c->query(AccountManager::class),
1043
-				$c->getGroupManager(),
1044
-				$c->getL10NFactory(),
1045
-				$c->getThemingDefaults(),
1046
-				$c->getAppManager()
1047
-			);
1048
-			return $manager;
1049
-		});
1050
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1051
-			return new \OC\Files\AppData\Factory(
1052
-				$c->getRootFolder(),
1053
-				$c->getSystemConfig()
1054
-			);
1055
-		});
1056
-
1057
-		$this->registerService('LockdownManager', function (Server $c) {
1058
-			return new LockdownManager(function () use ($c) {
1059
-				return $c->getSession();
1060
-			});
1061
-		});
1062
-
1063
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1064
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1065
-		});
1066
-
1067
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1068
-			return new CloudIdManager();
1069
-		});
1070
-
1071
-		/* To trick DI since we don't extend the DIContainer here */
1072
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1073
-			return new CleanPreviewsBackgroundJob(
1074
-				$c->getRootFolder(),
1075
-				$c->getLogger(),
1076
-				$c->getJobList(),
1077
-				new TimeFactory()
1078
-			);
1079
-		});
1080
-
1081
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1082
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1083
-
1084
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1085
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1086
-
1087
-		$this->registerService(Defaults::class, function (Server $c) {
1088
-			return new Defaults(
1089
-				$c->getThemingDefaults()
1090
-			);
1091
-		});
1092
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1093
-
1094
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1095
-			return $c->query(\OCP\IUserSession::class)->getSession();
1096
-		});
1097
-
1098
-		$this->registerService(IShareHelper::class, function (Server $c) {
1099
-			return new ShareHelper(
1100
-				$c->query(\OCP\Share\IManager::class)
1101
-			);
1102
-		});
1103
-
1104
-		$this->registerService(Installer::class, function(Server $c) {
1105
-			return new Installer(
1106
-				$c->getAppFetcher(),
1107
-				$c->getHTTPClientService(),
1108
-				$c->getTempManager(),
1109
-				$c->getLogger(),
1110
-				$c->getConfig()
1111
-			);
1112
-		});
1113
-
1114
-		$this->registerService(\OCP\Contacts\ContactsMenu\IContactsStore::class, function(Server $c) {
1115
-			return new ContactsStore(
1116
-				$this->getContactsManager(),
1117
-				$this->getConfig(),
1118
-				$this->getUserManager(),
1119
-				$this->getGroupManager()
1120
-			);
1121
-		});
1122
-	}
1123
-
1124
-	/**
1125
-	 * @return \OCP\Calendar\IManager
1126
-	 */
1127
-	public function getCalendarManager() {
1128
-		return $this->query('CalendarManager');
1129
-	}
1130
-
1131
-	/**
1132
-	 * @return \OCP\Contacts\IManager
1133
-	 */
1134
-	public function getContactsManager() {
1135
-		return $this->query('ContactsManager');
1136
-	}
1137
-
1138
-	/**
1139
-	 * @return \OC\Encryption\Manager
1140
-	 */
1141
-	public function getEncryptionManager() {
1142
-		return $this->query('EncryptionManager');
1143
-	}
1144
-
1145
-	/**
1146
-	 * @return \OC\Encryption\File
1147
-	 */
1148
-	public function getEncryptionFilesHelper() {
1149
-		return $this->query('EncryptionFileHelper');
1150
-	}
1151
-
1152
-	/**
1153
-	 * @return \OCP\Encryption\Keys\IStorage
1154
-	 */
1155
-	public function getEncryptionKeyStorage() {
1156
-		return $this->query('EncryptionKeyStorage');
1157
-	}
1158
-
1159
-	/**
1160
-	 * The current request object holding all information about the request
1161
-	 * currently being processed is returned from this method.
1162
-	 * In case the current execution was not initiated by a web request null is returned
1163
-	 *
1164
-	 * @return \OCP\IRequest
1165
-	 */
1166
-	public function getRequest() {
1167
-		return $this->query('Request');
1168
-	}
1169
-
1170
-	/**
1171
-	 * Returns the preview manager which can create preview images for a given file
1172
-	 *
1173
-	 * @return \OCP\IPreview
1174
-	 */
1175
-	public function getPreviewManager() {
1176
-		return $this->query('PreviewManager');
1177
-	}
1178
-
1179
-	/**
1180
-	 * Returns the tag manager which can get and set tags for different object types
1181
-	 *
1182
-	 * @see \OCP\ITagManager::load()
1183
-	 * @return \OCP\ITagManager
1184
-	 */
1185
-	public function getTagManager() {
1186
-		return $this->query('TagManager');
1187
-	}
1188
-
1189
-	/**
1190
-	 * Returns the system-tag manager
1191
-	 *
1192
-	 * @return \OCP\SystemTag\ISystemTagManager
1193
-	 *
1194
-	 * @since 9.0.0
1195
-	 */
1196
-	public function getSystemTagManager() {
1197
-		return $this->query('SystemTagManager');
1198
-	}
1199
-
1200
-	/**
1201
-	 * Returns the system-tag object mapper
1202
-	 *
1203
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1204
-	 *
1205
-	 * @since 9.0.0
1206
-	 */
1207
-	public function getSystemTagObjectMapper() {
1208
-		return $this->query('SystemTagObjectMapper');
1209
-	}
1210
-
1211
-	/**
1212
-	 * Returns the avatar manager, used for avatar functionality
1213
-	 *
1214
-	 * @return \OCP\IAvatarManager
1215
-	 */
1216
-	public function getAvatarManager() {
1217
-		return $this->query('AvatarManager');
1218
-	}
1219
-
1220
-	/**
1221
-	 * Returns the root folder of ownCloud's data directory
1222
-	 *
1223
-	 * @return \OCP\Files\IRootFolder
1224
-	 */
1225
-	public function getRootFolder() {
1226
-		return $this->query('LazyRootFolder');
1227
-	}
1228
-
1229
-	/**
1230
-	 * Returns the root folder of ownCloud's data directory
1231
-	 * This is the lazy variant so this gets only initialized once it
1232
-	 * is actually used.
1233
-	 *
1234
-	 * @return \OCP\Files\IRootFolder
1235
-	 */
1236
-	public function getLazyRootFolder() {
1237
-		return $this->query('LazyRootFolder');
1238
-	}
1239
-
1240
-	/**
1241
-	 * Returns a view to ownCloud's files folder
1242
-	 *
1243
-	 * @param string $userId user ID
1244
-	 * @return \OCP\Files\Folder|null
1245
-	 */
1246
-	public function getUserFolder($userId = null) {
1247
-		if ($userId === null) {
1248
-			$user = $this->getUserSession()->getUser();
1249
-			if (!$user) {
1250
-				return null;
1251
-			}
1252
-			$userId = $user->getUID();
1253
-		}
1254
-		$root = $this->getRootFolder();
1255
-		return $root->getUserFolder($userId);
1256
-	}
1257
-
1258
-	/**
1259
-	 * Returns an app-specific view in ownClouds data directory
1260
-	 *
1261
-	 * @return \OCP\Files\Folder
1262
-	 * @deprecated since 9.2.0 use IAppData
1263
-	 */
1264
-	public function getAppFolder() {
1265
-		$dir = '/' . \OC_App::getCurrentApp();
1266
-		$root = $this->getRootFolder();
1267
-		if (!$root->nodeExists($dir)) {
1268
-			$folder = $root->newFolder($dir);
1269
-		} else {
1270
-			$folder = $root->get($dir);
1271
-		}
1272
-		return $folder;
1273
-	}
1274
-
1275
-	/**
1276
-	 * @return \OC\User\Manager
1277
-	 */
1278
-	public function getUserManager() {
1279
-		return $this->query('UserManager');
1280
-	}
1281
-
1282
-	/**
1283
-	 * @return \OC\Group\Manager
1284
-	 */
1285
-	public function getGroupManager() {
1286
-		return $this->query('GroupManager');
1287
-	}
1288
-
1289
-	/**
1290
-	 * @return \OC\User\Session
1291
-	 */
1292
-	public function getUserSession() {
1293
-		return $this->query('UserSession');
1294
-	}
1295
-
1296
-	/**
1297
-	 * @return \OCP\ISession
1298
-	 */
1299
-	public function getSession() {
1300
-		return $this->query('UserSession')->getSession();
1301
-	}
1302
-
1303
-	/**
1304
-	 * @param \OCP\ISession $session
1305
-	 */
1306
-	public function setSession(\OCP\ISession $session) {
1307
-		$this->query(SessionStorage::class)->setSession($session);
1308
-		$this->query('UserSession')->setSession($session);
1309
-		$this->query(Store::class)->setSession($session);
1310
-	}
1311
-
1312
-	/**
1313
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1314
-	 */
1315
-	public function getTwoFactorAuthManager() {
1316
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1317
-	}
1318
-
1319
-	/**
1320
-	 * @return \OC\NavigationManager
1321
-	 */
1322
-	public function getNavigationManager() {
1323
-		return $this->query('NavigationManager');
1324
-	}
1325
-
1326
-	/**
1327
-	 * @return \OCP\IConfig
1328
-	 */
1329
-	public function getConfig() {
1330
-		return $this->query('AllConfig');
1331
-	}
1332
-
1333
-	/**
1334
-	 * @return \OC\SystemConfig
1335
-	 */
1336
-	public function getSystemConfig() {
1337
-		return $this->query('SystemConfig');
1338
-	}
1339
-
1340
-	/**
1341
-	 * Returns the app config manager
1342
-	 *
1343
-	 * @return \OCP\IAppConfig
1344
-	 */
1345
-	public function getAppConfig() {
1346
-		return $this->query('AppConfig');
1347
-	}
1348
-
1349
-	/**
1350
-	 * @return \OCP\L10N\IFactory
1351
-	 */
1352
-	public function getL10NFactory() {
1353
-		return $this->query('L10NFactory');
1354
-	}
1355
-
1356
-	/**
1357
-	 * get an L10N instance
1358
-	 *
1359
-	 * @param string $app appid
1360
-	 * @param string $lang
1361
-	 * @return IL10N
1362
-	 */
1363
-	public function getL10N($app, $lang = null) {
1364
-		return $this->getL10NFactory()->get($app, $lang);
1365
-	}
1366
-
1367
-	/**
1368
-	 * @return \OCP\IURLGenerator
1369
-	 */
1370
-	public function getURLGenerator() {
1371
-		return $this->query('URLGenerator');
1372
-	}
1373
-
1374
-	/**
1375
-	 * @return \OCP\IHelper
1376
-	 */
1377
-	public function getHelper() {
1378
-		return $this->query('AppHelper');
1379
-	}
1380
-
1381
-	/**
1382
-	 * @return AppFetcher
1383
-	 */
1384
-	public function getAppFetcher() {
1385
-		return $this->query(AppFetcher::class);
1386
-	}
1387
-
1388
-	/**
1389
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1390
-	 * getMemCacheFactory() instead.
1391
-	 *
1392
-	 * @return \OCP\ICache
1393
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1394
-	 */
1395
-	public function getCache() {
1396
-		return $this->query('UserCache');
1397
-	}
1398
-
1399
-	/**
1400
-	 * Returns an \OCP\CacheFactory instance
1401
-	 *
1402
-	 * @return \OCP\ICacheFactory
1403
-	 */
1404
-	public function getMemCacheFactory() {
1405
-		return $this->query('MemCacheFactory');
1406
-	}
1407
-
1408
-	/**
1409
-	 * Returns an \OC\RedisFactory instance
1410
-	 *
1411
-	 * @return \OC\RedisFactory
1412
-	 */
1413
-	public function getGetRedisFactory() {
1414
-		return $this->query('RedisFactory');
1415
-	}
1416
-
1417
-
1418
-	/**
1419
-	 * Returns the current session
1420
-	 *
1421
-	 * @return \OCP\IDBConnection
1422
-	 */
1423
-	public function getDatabaseConnection() {
1424
-		return $this->query('DatabaseConnection');
1425
-	}
1426
-
1427
-	/**
1428
-	 * Returns the activity manager
1429
-	 *
1430
-	 * @return \OCP\Activity\IManager
1431
-	 */
1432
-	public function getActivityManager() {
1433
-		return $this->query('ActivityManager');
1434
-	}
1435
-
1436
-	/**
1437
-	 * Returns an job list for controlling background jobs
1438
-	 *
1439
-	 * @return \OCP\BackgroundJob\IJobList
1440
-	 */
1441
-	public function getJobList() {
1442
-		return $this->query('JobList');
1443
-	}
1444
-
1445
-	/**
1446
-	 * Returns a logger instance
1447
-	 *
1448
-	 * @return \OCP\ILogger
1449
-	 */
1450
-	public function getLogger() {
1451
-		return $this->query('Logger');
1452
-	}
1453
-
1454
-	/**
1455
-	 * Returns a router for generating and matching urls
1456
-	 *
1457
-	 * @return \OCP\Route\IRouter
1458
-	 */
1459
-	public function getRouter() {
1460
-		return $this->query('Router');
1461
-	}
1462
-
1463
-	/**
1464
-	 * Returns a search instance
1465
-	 *
1466
-	 * @return \OCP\ISearch
1467
-	 */
1468
-	public function getSearch() {
1469
-		return $this->query('Search');
1470
-	}
1471
-
1472
-	/**
1473
-	 * Returns a SecureRandom instance
1474
-	 *
1475
-	 * @return \OCP\Security\ISecureRandom
1476
-	 */
1477
-	public function getSecureRandom() {
1478
-		return $this->query('SecureRandom');
1479
-	}
1480
-
1481
-	/**
1482
-	 * Returns a Crypto instance
1483
-	 *
1484
-	 * @return \OCP\Security\ICrypto
1485
-	 */
1486
-	public function getCrypto() {
1487
-		return $this->query('Crypto');
1488
-	}
1489
-
1490
-	/**
1491
-	 * Returns a Hasher instance
1492
-	 *
1493
-	 * @return \OCP\Security\IHasher
1494
-	 */
1495
-	public function getHasher() {
1496
-		return $this->query('Hasher');
1497
-	}
1498
-
1499
-	/**
1500
-	 * Returns a CredentialsManager instance
1501
-	 *
1502
-	 * @return \OCP\Security\ICredentialsManager
1503
-	 */
1504
-	public function getCredentialsManager() {
1505
-		return $this->query('CredentialsManager');
1506
-	}
1507
-
1508
-	/**
1509
-	 * Returns an instance of the HTTP helper class
1510
-	 *
1511
-	 * @deprecated Use getHTTPClientService()
1512
-	 * @return \OC\HTTPHelper
1513
-	 */
1514
-	public function getHTTPHelper() {
1515
-		return $this->query('HTTPHelper');
1516
-	}
1517
-
1518
-	/**
1519
-	 * Get the certificate manager for the user
1520
-	 *
1521
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1522
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1523
-	 */
1524
-	public function getCertificateManager($userId = '') {
1525
-		if ($userId === '') {
1526
-			$userSession = $this->getUserSession();
1527
-			$user = $userSession->getUser();
1528
-			if (is_null($user)) {
1529
-				return null;
1530
-			}
1531
-			$userId = $user->getUID();
1532
-		}
1533
-		return new CertificateManager(
1534
-			$userId,
1535
-			new View(),
1536
-			$this->getConfig(),
1537
-			$this->getLogger(),
1538
-			$this->getSecureRandom()
1539
-		);
1540
-	}
1541
-
1542
-	/**
1543
-	 * Returns an instance of the HTTP client service
1544
-	 *
1545
-	 * @return \OCP\Http\Client\IClientService
1546
-	 */
1547
-	public function getHTTPClientService() {
1548
-		return $this->query('HttpClientService');
1549
-	}
1550
-
1551
-	/**
1552
-	 * Create a new event source
1553
-	 *
1554
-	 * @return \OCP\IEventSource
1555
-	 */
1556
-	public function createEventSource() {
1557
-		return new \OC_EventSource();
1558
-	}
1559
-
1560
-	/**
1561
-	 * Get the active event logger
1562
-	 *
1563
-	 * The returned logger only logs data when debug mode is enabled
1564
-	 *
1565
-	 * @return \OCP\Diagnostics\IEventLogger
1566
-	 */
1567
-	public function getEventLogger() {
1568
-		return $this->query('EventLogger');
1569
-	}
1570
-
1571
-	/**
1572
-	 * Get the active query logger
1573
-	 *
1574
-	 * The returned logger only logs data when debug mode is enabled
1575
-	 *
1576
-	 * @return \OCP\Diagnostics\IQueryLogger
1577
-	 */
1578
-	public function getQueryLogger() {
1579
-		return $this->query('QueryLogger');
1580
-	}
1581
-
1582
-	/**
1583
-	 * Get the manager for temporary files and folders
1584
-	 *
1585
-	 * @return \OCP\ITempManager
1586
-	 */
1587
-	public function getTempManager() {
1588
-		return $this->query('TempManager');
1589
-	}
1590
-
1591
-	/**
1592
-	 * Get the app manager
1593
-	 *
1594
-	 * @return \OCP\App\IAppManager
1595
-	 */
1596
-	public function getAppManager() {
1597
-		return $this->query('AppManager');
1598
-	}
1599
-
1600
-	/**
1601
-	 * Creates a new mailer
1602
-	 *
1603
-	 * @return \OCP\Mail\IMailer
1604
-	 */
1605
-	public function getMailer() {
1606
-		return $this->query('Mailer');
1607
-	}
1608
-
1609
-	/**
1610
-	 * Get the webroot
1611
-	 *
1612
-	 * @return string
1613
-	 */
1614
-	public function getWebRoot() {
1615
-		return $this->webRoot;
1616
-	}
1617
-
1618
-	/**
1619
-	 * @return \OC\OCSClient
1620
-	 */
1621
-	public function getOcsClient() {
1622
-		return $this->query('OcsClient');
1623
-	}
1624
-
1625
-	/**
1626
-	 * @return \OCP\IDateTimeZone
1627
-	 */
1628
-	public function getDateTimeZone() {
1629
-		return $this->query('DateTimeZone');
1630
-	}
1631
-
1632
-	/**
1633
-	 * @return \OCP\IDateTimeFormatter
1634
-	 */
1635
-	public function getDateTimeFormatter() {
1636
-		return $this->query('DateTimeFormatter');
1637
-	}
1638
-
1639
-	/**
1640
-	 * @return \OCP\Files\Config\IMountProviderCollection
1641
-	 */
1642
-	public function getMountProviderCollection() {
1643
-		return $this->query('MountConfigManager');
1644
-	}
1645
-
1646
-	/**
1647
-	 * Get the IniWrapper
1648
-	 *
1649
-	 * @return IniGetWrapper
1650
-	 */
1651
-	public function getIniWrapper() {
1652
-		return $this->query('IniWrapper');
1653
-	}
1654
-
1655
-	/**
1656
-	 * @return \OCP\Command\IBus
1657
-	 */
1658
-	public function getCommandBus() {
1659
-		return $this->query('AsyncCommandBus');
1660
-	}
1661
-
1662
-	/**
1663
-	 * Get the trusted domain helper
1664
-	 *
1665
-	 * @return TrustedDomainHelper
1666
-	 */
1667
-	public function getTrustedDomainHelper() {
1668
-		return $this->query('TrustedDomainHelper');
1669
-	}
1670
-
1671
-	/**
1672
-	 * Get the locking provider
1673
-	 *
1674
-	 * @return \OCP\Lock\ILockingProvider
1675
-	 * @since 8.1.0
1676
-	 */
1677
-	public function getLockingProvider() {
1678
-		return $this->query('LockingProvider');
1679
-	}
1680
-
1681
-	/**
1682
-	 * @return \OCP\Files\Mount\IMountManager
1683
-	 **/
1684
-	function getMountManager() {
1685
-		return $this->query('MountManager');
1686
-	}
1687
-
1688
-	/** @return \OCP\Files\Config\IUserMountCache */
1689
-	function getUserMountCache() {
1690
-		return $this->query('UserMountCache');
1691
-	}
1692
-
1693
-	/**
1694
-	 * Get the MimeTypeDetector
1695
-	 *
1696
-	 * @return \OCP\Files\IMimeTypeDetector
1697
-	 */
1698
-	public function getMimeTypeDetector() {
1699
-		return $this->query('MimeTypeDetector');
1700
-	}
1701
-
1702
-	/**
1703
-	 * Get the MimeTypeLoader
1704
-	 *
1705
-	 * @return \OCP\Files\IMimeTypeLoader
1706
-	 */
1707
-	public function getMimeTypeLoader() {
1708
-		return $this->query('MimeTypeLoader');
1709
-	}
1710
-
1711
-	/**
1712
-	 * Get the manager of all the capabilities
1713
-	 *
1714
-	 * @return \OC\CapabilitiesManager
1715
-	 */
1716
-	public function getCapabilitiesManager() {
1717
-		return $this->query('CapabilitiesManager');
1718
-	}
1719
-
1720
-	/**
1721
-	 * Get the EventDispatcher
1722
-	 *
1723
-	 * @return EventDispatcherInterface
1724
-	 * @since 8.2.0
1725
-	 */
1726
-	public function getEventDispatcher() {
1727
-		return $this->query('EventDispatcher');
1728
-	}
1729
-
1730
-	/**
1731
-	 * Get the Notification Manager
1732
-	 *
1733
-	 * @return \OCP\Notification\IManager
1734
-	 * @since 8.2.0
1735
-	 */
1736
-	public function getNotificationManager() {
1737
-		return $this->query('NotificationManager');
1738
-	}
1739
-
1740
-	/**
1741
-	 * @return \OCP\Comments\ICommentsManager
1742
-	 */
1743
-	public function getCommentsManager() {
1744
-		return $this->query('CommentsManager');
1745
-	}
1746
-
1747
-	/**
1748
-	 * @return \OCA\Theming\ThemingDefaults
1749
-	 */
1750
-	public function getThemingDefaults() {
1751
-		return $this->query('ThemingDefaults');
1752
-	}
1753
-
1754
-	/**
1755
-	 * @return \OC\IntegrityCheck\Checker
1756
-	 */
1757
-	public function getIntegrityCodeChecker() {
1758
-		return $this->query('IntegrityCodeChecker');
1759
-	}
1760
-
1761
-	/**
1762
-	 * @return \OC\Session\CryptoWrapper
1763
-	 */
1764
-	public function getSessionCryptoWrapper() {
1765
-		return $this->query('CryptoWrapper');
1766
-	}
1767
-
1768
-	/**
1769
-	 * @return CsrfTokenManager
1770
-	 */
1771
-	public function getCsrfTokenManager() {
1772
-		return $this->query('CsrfTokenManager');
1773
-	}
1774
-
1775
-	/**
1776
-	 * @return Throttler
1777
-	 */
1778
-	public function getBruteForceThrottler() {
1779
-		return $this->query('Throttler');
1780
-	}
1781
-
1782
-	/**
1783
-	 * @return IContentSecurityPolicyManager
1784
-	 */
1785
-	public function getContentSecurityPolicyManager() {
1786
-		return $this->query('ContentSecurityPolicyManager');
1787
-	}
1788
-
1789
-	/**
1790
-	 * @return ContentSecurityPolicyNonceManager
1791
-	 */
1792
-	public function getContentSecurityPolicyNonceManager() {
1793
-		return $this->query('ContentSecurityPolicyNonceManager');
1794
-	}
1795
-
1796
-	/**
1797
-	 * Not a public API as of 8.2, wait for 9.0
1798
-	 *
1799
-	 * @return \OCA\Files_External\Service\BackendService
1800
-	 */
1801
-	public function getStoragesBackendService() {
1802
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1803
-	}
1804
-
1805
-	/**
1806
-	 * Not a public API as of 8.2, wait for 9.0
1807
-	 *
1808
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1809
-	 */
1810
-	public function getGlobalStoragesService() {
1811
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1812
-	}
1813
-
1814
-	/**
1815
-	 * Not a public API as of 8.2, wait for 9.0
1816
-	 *
1817
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1818
-	 */
1819
-	public function getUserGlobalStoragesService() {
1820
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1821
-	}
1822
-
1823
-	/**
1824
-	 * Not a public API as of 8.2, wait for 9.0
1825
-	 *
1826
-	 * @return \OCA\Files_External\Service\UserStoragesService
1827
-	 */
1828
-	public function getUserStoragesService() {
1829
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1830
-	}
1831
-
1832
-	/**
1833
-	 * @return \OCP\Share\IManager
1834
-	 */
1835
-	public function getShareManager() {
1836
-		return $this->query('ShareManager');
1837
-	}
1838
-
1839
-	/**
1840
-	 * @return \OCP\Collaboration\Collaborators\ISearch
1841
-	 */
1842
-	public function getCollaboratorSearch() {
1843
-		return $this->query('CollaboratorSearch');
1844
-	}
1845
-
1846
-	/**
1847
-	 * @return \OCP\Collaboration\AutoComplete\IManager
1848
-	 */
1849
-	public function getAutoCompleteManager(){
1850
-		return $this->query(IManager::class);
1851
-	}
1852
-
1853
-	/**
1854
-	 * Returns the LDAP Provider
1855
-	 *
1856
-	 * @return \OCP\LDAP\ILDAPProvider
1857
-	 */
1858
-	public function getLDAPProvider() {
1859
-		return $this->query('LDAPProvider');
1860
-	}
1861
-
1862
-	/**
1863
-	 * @return \OCP\Settings\IManager
1864
-	 */
1865
-	public function getSettingsManager() {
1866
-		return $this->query('SettingsManager');
1867
-	}
1868
-
1869
-	/**
1870
-	 * @return \OCP\Files\IAppData
1871
-	 */
1872
-	public function getAppDataDir($app) {
1873
-		/** @var \OC\Files\AppData\Factory $factory */
1874
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1875
-		return $factory->get($app);
1876
-	}
1877
-
1878
-	/**
1879
-	 * @return \OCP\Lockdown\ILockdownManager
1880
-	 */
1881
-	public function getLockdownManager() {
1882
-		return $this->query('LockdownManager');
1883
-	}
1884
-
1885
-	/**
1886
-	 * @return \OCP\Federation\ICloudIdManager
1887
-	 */
1888
-	public function getCloudIdManager() {
1889
-		return $this->query(ICloudIdManager::class);
1890
-	}
900
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
901
+            if (isset($prefixes['OCA\\Theming\\'])) {
902
+                $classExists = true;
903
+            } else {
904
+                $classExists = false;
905
+            }
906
+
907
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
908
+                return new ThemingDefaults(
909
+                    $c->getConfig(),
910
+                    $c->getL10N('theming'),
911
+                    $c->getURLGenerator(),
912
+                    $c->getAppDataDir('theming'),
913
+                    $c->getMemCacheFactory(),
914
+                    new Util($c->getConfig(), $this->getAppManager(), $this->getAppDataDir('theming')),
915
+                    $this->getAppManager()
916
+                );
917
+            }
918
+            return new \OC_Defaults();
919
+        });
920
+        $this->registerService(SCSSCacher::class, function (Server $c) {
921
+            /** @var Factory $cacheFactory */
922
+            $cacheFactory = $c->query(Factory::class);
923
+            return new SCSSCacher(
924
+                $c->getLogger(),
925
+                $c->query(\OC\Files\AppData\Factory::class),
926
+                $c->getURLGenerator(),
927
+                $c->getConfig(),
928
+                $c->getThemingDefaults(),
929
+                \OC::$SERVERROOT,
930
+                $cacheFactory->create('SCSS')
931
+            );
932
+        });
933
+        $this->registerService(EventDispatcher::class, function () {
934
+            return new EventDispatcher();
935
+        });
936
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
937
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
938
+
939
+        $this->registerService('CryptoWrapper', function (Server $c) {
940
+            // FIXME: Instantiiated here due to cyclic dependency
941
+            $request = new Request(
942
+                [
943
+                    'get' => $_GET,
944
+                    'post' => $_POST,
945
+                    'files' => $_FILES,
946
+                    'server' => $_SERVER,
947
+                    'env' => $_ENV,
948
+                    'cookies' => $_COOKIE,
949
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
950
+                        ? $_SERVER['REQUEST_METHOD']
951
+                        : null,
952
+                ],
953
+                $c->getSecureRandom(),
954
+                $c->getConfig()
955
+            );
956
+
957
+            return new CryptoWrapper(
958
+                $c->getConfig(),
959
+                $c->getCrypto(),
960
+                $c->getSecureRandom(),
961
+                $request
962
+            );
963
+        });
964
+        $this->registerService('CsrfTokenManager', function (Server $c) {
965
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
966
+
967
+            return new CsrfTokenManager(
968
+                $tokenGenerator,
969
+                $c->query(SessionStorage::class)
970
+            );
971
+        });
972
+        $this->registerService(SessionStorage::class, function (Server $c) {
973
+            return new SessionStorage($c->getSession());
974
+        });
975
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
976
+            return new ContentSecurityPolicyManager();
977
+        });
978
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
979
+
980
+        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
981
+            return new ContentSecurityPolicyNonceManager(
982
+                $c->getCsrfTokenManager(),
983
+                $c->getRequest()
984
+            );
985
+        });
986
+
987
+        $this->registerService(\OCP\Share\IManager::class, function (Server $c) {
988
+            $config = $c->getConfig();
989
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
990
+            /** @var \OCP\Share\IProviderFactory $factory */
991
+            $factory = new $factoryClass($this);
992
+
993
+            $manager = new \OC\Share20\Manager(
994
+                $c->getLogger(),
995
+                $c->getConfig(),
996
+                $c->getSecureRandom(),
997
+                $c->getHasher(),
998
+                $c->getMountManager(),
999
+                $c->getGroupManager(),
1000
+                $c->getL10N('lib'),
1001
+                $c->getL10NFactory(),
1002
+                $factory,
1003
+                $c->getUserManager(),
1004
+                $c->getLazyRootFolder(),
1005
+                $c->getEventDispatcher(),
1006
+                $c->getMailer(),
1007
+                $c->getURLGenerator(),
1008
+                $c->getThemingDefaults()
1009
+            );
1010
+
1011
+            return $manager;
1012
+        });
1013
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1014
+
1015
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1016
+            $instance = new Collaboration\Collaborators\Search($c);
1017
+
1018
+            // register default plugins
1019
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1020
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1021
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1022
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1023
+
1024
+            return $instance;
1025
+        });
1026
+        $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1027
+
1028
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1029
+
1030
+        $this->registerService('SettingsManager', function (Server $c) {
1031
+            $manager = new \OC\Settings\Manager(
1032
+                $c->getLogger(),
1033
+                $c->getDatabaseConnection(),
1034
+                $c->getL10N('lib'),
1035
+                $c->getConfig(),
1036
+                $c->getEncryptionManager(),
1037
+                $c->getUserManager(),
1038
+                $c->getLockingProvider(),
1039
+                $c->getRequest(),
1040
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
1041
+                $c->getURLGenerator(),
1042
+                $c->query(AccountManager::class),
1043
+                $c->getGroupManager(),
1044
+                $c->getL10NFactory(),
1045
+                $c->getThemingDefaults(),
1046
+                $c->getAppManager()
1047
+            );
1048
+            return $manager;
1049
+        });
1050
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1051
+            return new \OC\Files\AppData\Factory(
1052
+                $c->getRootFolder(),
1053
+                $c->getSystemConfig()
1054
+            );
1055
+        });
1056
+
1057
+        $this->registerService('LockdownManager', function (Server $c) {
1058
+            return new LockdownManager(function () use ($c) {
1059
+                return $c->getSession();
1060
+            });
1061
+        });
1062
+
1063
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1064
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1065
+        });
1066
+
1067
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1068
+            return new CloudIdManager();
1069
+        });
1070
+
1071
+        /* To trick DI since we don't extend the DIContainer here */
1072
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
1073
+            return new CleanPreviewsBackgroundJob(
1074
+                $c->getRootFolder(),
1075
+                $c->getLogger(),
1076
+                $c->getJobList(),
1077
+                new TimeFactory()
1078
+            );
1079
+        });
1080
+
1081
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1082
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1083
+
1084
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1085
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1086
+
1087
+        $this->registerService(Defaults::class, function (Server $c) {
1088
+            return new Defaults(
1089
+                $c->getThemingDefaults()
1090
+            );
1091
+        });
1092
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1093
+
1094
+        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1095
+            return $c->query(\OCP\IUserSession::class)->getSession();
1096
+        });
1097
+
1098
+        $this->registerService(IShareHelper::class, function (Server $c) {
1099
+            return new ShareHelper(
1100
+                $c->query(\OCP\Share\IManager::class)
1101
+            );
1102
+        });
1103
+
1104
+        $this->registerService(Installer::class, function(Server $c) {
1105
+            return new Installer(
1106
+                $c->getAppFetcher(),
1107
+                $c->getHTTPClientService(),
1108
+                $c->getTempManager(),
1109
+                $c->getLogger(),
1110
+                $c->getConfig()
1111
+            );
1112
+        });
1113
+
1114
+        $this->registerService(\OCP\Contacts\ContactsMenu\IContactsStore::class, function(Server $c) {
1115
+            return new ContactsStore(
1116
+                $this->getContactsManager(),
1117
+                $this->getConfig(),
1118
+                $this->getUserManager(),
1119
+                $this->getGroupManager()
1120
+            );
1121
+        });
1122
+    }
1123
+
1124
+    /**
1125
+     * @return \OCP\Calendar\IManager
1126
+     */
1127
+    public function getCalendarManager() {
1128
+        return $this->query('CalendarManager');
1129
+    }
1130
+
1131
+    /**
1132
+     * @return \OCP\Contacts\IManager
1133
+     */
1134
+    public function getContactsManager() {
1135
+        return $this->query('ContactsManager');
1136
+    }
1137
+
1138
+    /**
1139
+     * @return \OC\Encryption\Manager
1140
+     */
1141
+    public function getEncryptionManager() {
1142
+        return $this->query('EncryptionManager');
1143
+    }
1144
+
1145
+    /**
1146
+     * @return \OC\Encryption\File
1147
+     */
1148
+    public function getEncryptionFilesHelper() {
1149
+        return $this->query('EncryptionFileHelper');
1150
+    }
1151
+
1152
+    /**
1153
+     * @return \OCP\Encryption\Keys\IStorage
1154
+     */
1155
+    public function getEncryptionKeyStorage() {
1156
+        return $this->query('EncryptionKeyStorage');
1157
+    }
1158
+
1159
+    /**
1160
+     * The current request object holding all information about the request
1161
+     * currently being processed is returned from this method.
1162
+     * In case the current execution was not initiated by a web request null is returned
1163
+     *
1164
+     * @return \OCP\IRequest
1165
+     */
1166
+    public function getRequest() {
1167
+        return $this->query('Request');
1168
+    }
1169
+
1170
+    /**
1171
+     * Returns the preview manager which can create preview images for a given file
1172
+     *
1173
+     * @return \OCP\IPreview
1174
+     */
1175
+    public function getPreviewManager() {
1176
+        return $this->query('PreviewManager');
1177
+    }
1178
+
1179
+    /**
1180
+     * Returns the tag manager which can get and set tags for different object types
1181
+     *
1182
+     * @see \OCP\ITagManager::load()
1183
+     * @return \OCP\ITagManager
1184
+     */
1185
+    public function getTagManager() {
1186
+        return $this->query('TagManager');
1187
+    }
1188
+
1189
+    /**
1190
+     * Returns the system-tag manager
1191
+     *
1192
+     * @return \OCP\SystemTag\ISystemTagManager
1193
+     *
1194
+     * @since 9.0.0
1195
+     */
1196
+    public function getSystemTagManager() {
1197
+        return $this->query('SystemTagManager');
1198
+    }
1199
+
1200
+    /**
1201
+     * Returns the system-tag object mapper
1202
+     *
1203
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1204
+     *
1205
+     * @since 9.0.0
1206
+     */
1207
+    public function getSystemTagObjectMapper() {
1208
+        return $this->query('SystemTagObjectMapper');
1209
+    }
1210
+
1211
+    /**
1212
+     * Returns the avatar manager, used for avatar functionality
1213
+     *
1214
+     * @return \OCP\IAvatarManager
1215
+     */
1216
+    public function getAvatarManager() {
1217
+        return $this->query('AvatarManager');
1218
+    }
1219
+
1220
+    /**
1221
+     * Returns the root folder of ownCloud's data directory
1222
+     *
1223
+     * @return \OCP\Files\IRootFolder
1224
+     */
1225
+    public function getRootFolder() {
1226
+        return $this->query('LazyRootFolder');
1227
+    }
1228
+
1229
+    /**
1230
+     * Returns the root folder of ownCloud's data directory
1231
+     * This is the lazy variant so this gets only initialized once it
1232
+     * is actually used.
1233
+     *
1234
+     * @return \OCP\Files\IRootFolder
1235
+     */
1236
+    public function getLazyRootFolder() {
1237
+        return $this->query('LazyRootFolder');
1238
+    }
1239
+
1240
+    /**
1241
+     * Returns a view to ownCloud's files folder
1242
+     *
1243
+     * @param string $userId user ID
1244
+     * @return \OCP\Files\Folder|null
1245
+     */
1246
+    public function getUserFolder($userId = null) {
1247
+        if ($userId === null) {
1248
+            $user = $this->getUserSession()->getUser();
1249
+            if (!$user) {
1250
+                return null;
1251
+            }
1252
+            $userId = $user->getUID();
1253
+        }
1254
+        $root = $this->getRootFolder();
1255
+        return $root->getUserFolder($userId);
1256
+    }
1257
+
1258
+    /**
1259
+     * Returns an app-specific view in ownClouds data directory
1260
+     *
1261
+     * @return \OCP\Files\Folder
1262
+     * @deprecated since 9.2.0 use IAppData
1263
+     */
1264
+    public function getAppFolder() {
1265
+        $dir = '/' . \OC_App::getCurrentApp();
1266
+        $root = $this->getRootFolder();
1267
+        if (!$root->nodeExists($dir)) {
1268
+            $folder = $root->newFolder($dir);
1269
+        } else {
1270
+            $folder = $root->get($dir);
1271
+        }
1272
+        return $folder;
1273
+    }
1274
+
1275
+    /**
1276
+     * @return \OC\User\Manager
1277
+     */
1278
+    public function getUserManager() {
1279
+        return $this->query('UserManager');
1280
+    }
1281
+
1282
+    /**
1283
+     * @return \OC\Group\Manager
1284
+     */
1285
+    public function getGroupManager() {
1286
+        return $this->query('GroupManager');
1287
+    }
1288
+
1289
+    /**
1290
+     * @return \OC\User\Session
1291
+     */
1292
+    public function getUserSession() {
1293
+        return $this->query('UserSession');
1294
+    }
1295
+
1296
+    /**
1297
+     * @return \OCP\ISession
1298
+     */
1299
+    public function getSession() {
1300
+        return $this->query('UserSession')->getSession();
1301
+    }
1302
+
1303
+    /**
1304
+     * @param \OCP\ISession $session
1305
+     */
1306
+    public function setSession(\OCP\ISession $session) {
1307
+        $this->query(SessionStorage::class)->setSession($session);
1308
+        $this->query('UserSession')->setSession($session);
1309
+        $this->query(Store::class)->setSession($session);
1310
+    }
1311
+
1312
+    /**
1313
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1314
+     */
1315
+    public function getTwoFactorAuthManager() {
1316
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1317
+    }
1318
+
1319
+    /**
1320
+     * @return \OC\NavigationManager
1321
+     */
1322
+    public function getNavigationManager() {
1323
+        return $this->query('NavigationManager');
1324
+    }
1325
+
1326
+    /**
1327
+     * @return \OCP\IConfig
1328
+     */
1329
+    public function getConfig() {
1330
+        return $this->query('AllConfig');
1331
+    }
1332
+
1333
+    /**
1334
+     * @return \OC\SystemConfig
1335
+     */
1336
+    public function getSystemConfig() {
1337
+        return $this->query('SystemConfig');
1338
+    }
1339
+
1340
+    /**
1341
+     * Returns the app config manager
1342
+     *
1343
+     * @return \OCP\IAppConfig
1344
+     */
1345
+    public function getAppConfig() {
1346
+        return $this->query('AppConfig');
1347
+    }
1348
+
1349
+    /**
1350
+     * @return \OCP\L10N\IFactory
1351
+     */
1352
+    public function getL10NFactory() {
1353
+        return $this->query('L10NFactory');
1354
+    }
1355
+
1356
+    /**
1357
+     * get an L10N instance
1358
+     *
1359
+     * @param string $app appid
1360
+     * @param string $lang
1361
+     * @return IL10N
1362
+     */
1363
+    public function getL10N($app, $lang = null) {
1364
+        return $this->getL10NFactory()->get($app, $lang);
1365
+    }
1366
+
1367
+    /**
1368
+     * @return \OCP\IURLGenerator
1369
+     */
1370
+    public function getURLGenerator() {
1371
+        return $this->query('URLGenerator');
1372
+    }
1373
+
1374
+    /**
1375
+     * @return \OCP\IHelper
1376
+     */
1377
+    public function getHelper() {
1378
+        return $this->query('AppHelper');
1379
+    }
1380
+
1381
+    /**
1382
+     * @return AppFetcher
1383
+     */
1384
+    public function getAppFetcher() {
1385
+        return $this->query(AppFetcher::class);
1386
+    }
1387
+
1388
+    /**
1389
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1390
+     * getMemCacheFactory() instead.
1391
+     *
1392
+     * @return \OCP\ICache
1393
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1394
+     */
1395
+    public function getCache() {
1396
+        return $this->query('UserCache');
1397
+    }
1398
+
1399
+    /**
1400
+     * Returns an \OCP\CacheFactory instance
1401
+     *
1402
+     * @return \OCP\ICacheFactory
1403
+     */
1404
+    public function getMemCacheFactory() {
1405
+        return $this->query('MemCacheFactory');
1406
+    }
1407
+
1408
+    /**
1409
+     * Returns an \OC\RedisFactory instance
1410
+     *
1411
+     * @return \OC\RedisFactory
1412
+     */
1413
+    public function getGetRedisFactory() {
1414
+        return $this->query('RedisFactory');
1415
+    }
1416
+
1417
+
1418
+    /**
1419
+     * Returns the current session
1420
+     *
1421
+     * @return \OCP\IDBConnection
1422
+     */
1423
+    public function getDatabaseConnection() {
1424
+        return $this->query('DatabaseConnection');
1425
+    }
1426
+
1427
+    /**
1428
+     * Returns the activity manager
1429
+     *
1430
+     * @return \OCP\Activity\IManager
1431
+     */
1432
+    public function getActivityManager() {
1433
+        return $this->query('ActivityManager');
1434
+    }
1435
+
1436
+    /**
1437
+     * Returns an job list for controlling background jobs
1438
+     *
1439
+     * @return \OCP\BackgroundJob\IJobList
1440
+     */
1441
+    public function getJobList() {
1442
+        return $this->query('JobList');
1443
+    }
1444
+
1445
+    /**
1446
+     * Returns a logger instance
1447
+     *
1448
+     * @return \OCP\ILogger
1449
+     */
1450
+    public function getLogger() {
1451
+        return $this->query('Logger');
1452
+    }
1453
+
1454
+    /**
1455
+     * Returns a router for generating and matching urls
1456
+     *
1457
+     * @return \OCP\Route\IRouter
1458
+     */
1459
+    public function getRouter() {
1460
+        return $this->query('Router');
1461
+    }
1462
+
1463
+    /**
1464
+     * Returns a search instance
1465
+     *
1466
+     * @return \OCP\ISearch
1467
+     */
1468
+    public function getSearch() {
1469
+        return $this->query('Search');
1470
+    }
1471
+
1472
+    /**
1473
+     * Returns a SecureRandom instance
1474
+     *
1475
+     * @return \OCP\Security\ISecureRandom
1476
+     */
1477
+    public function getSecureRandom() {
1478
+        return $this->query('SecureRandom');
1479
+    }
1480
+
1481
+    /**
1482
+     * Returns a Crypto instance
1483
+     *
1484
+     * @return \OCP\Security\ICrypto
1485
+     */
1486
+    public function getCrypto() {
1487
+        return $this->query('Crypto');
1488
+    }
1489
+
1490
+    /**
1491
+     * Returns a Hasher instance
1492
+     *
1493
+     * @return \OCP\Security\IHasher
1494
+     */
1495
+    public function getHasher() {
1496
+        return $this->query('Hasher');
1497
+    }
1498
+
1499
+    /**
1500
+     * Returns a CredentialsManager instance
1501
+     *
1502
+     * @return \OCP\Security\ICredentialsManager
1503
+     */
1504
+    public function getCredentialsManager() {
1505
+        return $this->query('CredentialsManager');
1506
+    }
1507
+
1508
+    /**
1509
+     * Returns an instance of the HTTP helper class
1510
+     *
1511
+     * @deprecated Use getHTTPClientService()
1512
+     * @return \OC\HTTPHelper
1513
+     */
1514
+    public function getHTTPHelper() {
1515
+        return $this->query('HTTPHelper');
1516
+    }
1517
+
1518
+    /**
1519
+     * Get the certificate manager for the user
1520
+     *
1521
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1522
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1523
+     */
1524
+    public function getCertificateManager($userId = '') {
1525
+        if ($userId === '') {
1526
+            $userSession = $this->getUserSession();
1527
+            $user = $userSession->getUser();
1528
+            if (is_null($user)) {
1529
+                return null;
1530
+            }
1531
+            $userId = $user->getUID();
1532
+        }
1533
+        return new CertificateManager(
1534
+            $userId,
1535
+            new View(),
1536
+            $this->getConfig(),
1537
+            $this->getLogger(),
1538
+            $this->getSecureRandom()
1539
+        );
1540
+    }
1541
+
1542
+    /**
1543
+     * Returns an instance of the HTTP client service
1544
+     *
1545
+     * @return \OCP\Http\Client\IClientService
1546
+     */
1547
+    public function getHTTPClientService() {
1548
+        return $this->query('HttpClientService');
1549
+    }
1550
+
1551
+    /**
1552
+     * Create a new event source
1553
+     *
1554
+     * @return \OCP\IEventSource
1555
+     */
1556
+    public function createEventSource() {
1557
+        return new \OC_EventSource();
1558
+    }
1559
+
1560
+    /**
1561
+     * Get the active event logger
1562
+     *
1563
+     * The returned logger only logs data when debug mode is enabled
1564
+     *
1565
+     * @return \OCP\Diagnostics\IEventLogger
1566
+     */
1567
+    public function getEventLogger() {
1568
+        return $this->query('EventLogger');
1569
+    }
1570
+
1571
+    /**
1572
+     * Get the active query logger
1573
+     *
1574
+     * The returned logger only logs data when debug mode is enabled
1575
+     *
1576
+     * @return \OCP\Diagnostics\IQueryLogger
1577
+     */
1578
+    public function getQueryLogger() {
1579
+        return $this->query('QueryLogger');
1580
+    }
1581
+
1582
+    /**
1583
+     * Get the manager for temporary files and folders
1584
+     *
1585
+     * @return \OCP\ITempManager
1586
+     */
1587
+    public function getTempManager() {
1588
+        return $this->query('TempManager');
1589
+    }
1590
+
1591
+    /**
1592
+     * Get the app manager
1593
+     *
1594
+     * @return \OCP\App\IAppManager
1595
+     */
1596
+    public function getAppManager() {
1597
+        return $this->query('AppManager');
1598
+    }
1599
+
1600
+    /**
1601
+     * Creates a new mailer
1602
+     *
1603
+     * @return \OCP\Mail\IMailer
1604
+     */
1605
+    public function getMailer() {
1606
+        return $this->query('Mailer');
1607
+    }
1608
+
1609
+    /**
1610
+     * Get the webroot
1611
+     *
1612
+     * @return string
1613
+     */
1614
+    public function getWebRoot() {
1615
+        return $this->webRoot;
1616
+    }
1617
+
1618
+    /**
1619
+     * @return \OC\OCSClient
1620
+     */
1621
+    public function getOcsClient() {
1622
+        return $this->query('OcsClient');
1623
+    }
1624
+
1625
+    /**
1626
+     * @return \OCP\IDateTimeZone
1627
+     */
1628
+    public function getDateTimeZone() {
1629
+        return $this->query('DateTimeZone');
1630
+    }
1631
+
1632
+    /**
1633
+     * @return \OCP\IDateTimeFormatter
1634
+     */
1635
+    public function getDateTimeFormatter() {
1636
+        return $this->query('DateTimeFormatter');
1637
+    }
1638
+
1639
+    /**
1640
+     * @return \OCP\Files\Config\IMountProviderCollection
1641
+     */
1642
+    public function getMountProviderCollection() {
1643
+        return $this->query('MountConfigManager');
1644
+    }
1645
+
1646
+    /**
1647
+     * Get the IniWrapper
1648
+     *
1649
+     * @return IniGetWrapper
1650
+     */
1651
+    public function getIniWrapper() {
1652
+        return $this->query('IniWrapper');
1653
+    }
1654
+
1655
+    /**
1656
+     * @return \OCP\Command\IBus
1657
+     */
1658
+    public function getCommandBus() {
1659
+        return $this->query('AsyncCommandBus');
1660
+    }
1661
+
1662
+    /**
1663
+     * Get the trusted domain helper
1664
+     *
1665
+     * @return TrustedDomainHelper
1666
+     */
1667
+    public function getTrustedDomainHelper() {
1668
+        return $this->query('TrustedDomainHelper');
1669
+    }
1670
+
1671
+    /**
1672
+     * Get the locking provider
1673
+     *
1674
+     * @return \OCP\Lock\ILockingProvider
1675
+     * @since 8.1.0
1676
+     */
1677
+    public function getLockingProvider() {
1678
+        return $this->query('LockingProvider');
1679
+    }
1680
+
1681
+    /**
1682
+     * @return \OCP\Files\Mount\IMountManager
1683
+     **/
1684
+    function getMountManager() {
1685
+        return $this->query('MountManager');
1686
+    }
1687
+
1688
+    /** @return \OCP\Files\Config\IUserMountCache */
1689
+    function getUserMountCache() {
1690
+        return $this->query('UserMountCache');
1691
+    }
1692
+
1693
+    /**
1694
+     * Get the MimeTypeDetector
1695
+     *
1696
+     * @return \OCP\Files\IMimeTypeDetector
1697
+     */
1698
+    public function getMimeTypeDetector() {
1699
+        return $this->query('MimeTypeDetector');
1700
+    }
1701
+
1702
+    /**
1703
+     * Get the MimeTypeLoader
1704
+     *
1705
+     * @return \OCP\Files\IMimeTypeLoader
1706
+     */
1707
+    public function getMimeTypeLoader() {
1708
+        return $this->query('MimeTypeLoader');
1709
+    }
1710
+
1711
+    /**
1712
+     * Get the manager of all the capabilities
1713
+     *
1714
+     * @return \OC\CapabilitiesManager
1715
+     */
1716
+    public function getCapabilitiesManager() {
1717
+        return $this->query('CapabilitiesManager');
1718
+    }
1719
+
1720
+    /**
1721
+     * Get the EventDispatcher
1722
+     *
1723
+     * @return EventDispatcherInterface
1724
+     * @since 8.2.0
1725
+     */
1726
+    public function getEventDispatcher() {
1727
+        return $this->query('EventDispatcher');
1728
+    }
1729
+
1730
+    /**
1731
+     * Get the Notification Manager
1732
+     *
1733
+     * @return \OCP\Notification\IManager
1734
+     * @since 8.2.0
1735
+     */
1736
+    public function getNotificationManager() {
1737
+        return $this->query('NotificationManager');
1738
+    }
1739
+
1740
+    /**
1741
+     * @return \OCP\Comments\ICommentsManager
1742
+     */
1743
+    public function getCommentsManager() {
1744
+        return $this->query('CommentsManager');
1745
+    }
1746
+
1747
+    /**
1748
+     * @return \OCA\Theming\ThemingDefaults
1749
+     */
1750
+    public function getThemingDefaults() {
1751
+        return $this->query('ThemingDefaults');
1752
+    }
1753
+
1754
+    /**
1755
+     * @return \OC\IntegrityCheck\Checker
1756
+     */
1757
+    public function getIntegrityCodeChecker() {
1758
+        return $this->query('IntegrityCodeChecker');
1759
+    }
1760
+
1761
+    /**
1762
+     * @return \OC\Session\CryptoWrapper
1763
+     */
1764
+    public function getSessionCryptoWrapper() {
1765
+        return $this->query('CryptoWrapper');
1766
+    }
1767
+
1768
+    /**
1769
+     * @return CsrfTokenManager
1770
+     */
1771
+    public function getCsrfTokenManager() {
1772
+        return $this->query('CsrfTokenManager');
1773
+    }
1774
+
1775
+    /**
1776
+     * @return Throttler
1777
+     */
1778
+    public function getBruteForceThrottler() {
1779
+        return $this->query('Throttler');
1780
+    }
1781
+
1782
+    /**
1783
+     * @return IContentSecurityPolicyManager
1784
+     */
1785
+    public function getContentSecurityPolicyManager() {
1786
+        return $this->query('ContentSecurityPolicyManager');
1787
+    }
1788
+
1789
+    /**
1790
+     * @return ContentSecurityPolicyNonceManager
1791
+     */
1792
+    public function getContentSecurityPolicyNonceManager() {
1793
+        return $this->query('ContentSecurityPolicyNonceManager');
1794
+    }
1795
+
1796
+    /**
1797
+     * Not a public API as of 8.2, wait for 9.0
1798
+     *
1799
+     * @return \OCA\Files_External\Service\BackendService
1800
+     */
1801
+    public function getStoragesBackendService() {
1802
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1803
+    }
1804
+
1805
+    /**
1806
+     * Not a public API as of 8.2, wait for 9.0
1807
+     *
1808
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1809
+     */
1810
+    public function getGlobalStoragesService() {
1811
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1812
+    }
1813
+
1814
+    /**
1815
+     * Not a public API as of 8.2, wait for 9.0
1816
+     *
1817
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1818
+     */
1819
+    public function getUserGlobalStoragesService() {
1820
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1821
+    }
1822
+
1823
+    /**
1824
+     * Not a public API as of 8.2, wait for 9.0
1825
+     *
1826
+     * @return \OCA\Files_External\Service\UserStoragesService
1827
+     */
1828
+    public function getUserStoragesService() {
1829
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1830
+    }
1831
+
1832
+    /**
1833
+     * @return \OCP\Share\IManager
1834
+     */
1835
+    public function getShareManager() {
1836
+        return $this->query('ShareManager');
1837
+    }
1838
+
1839
+    /**
1840
+     * @return \OCP\Collaboration\Collaborators\ISearch
1841
+     */
1842
+    public function getCollaboratorSearch() {
1843
+        return $this->query('CollaboratorSearch');
1844
+    }
1845
+
1846
+    /**
1847
+     * @return \OCP\Collaboration\AutoComplete\IManager
1848
+     */
1849
+    public function getAutoCompleteManager(){
1850
+        return $this->query(IManager::class);
1851
+    }
1852
+
1853
+    /**
1854
+     * Returns the LDAP Provider
1855
+     *
1856
+     * @return \OCP\LDAP\ILDAPProvider
1857
+     */
1858
+    public function getLDAPProvider() {
1859
+        return $this->query('LDAPProvider');
1860
+    }
1861
+
1862
+    /**
1863
+     * @return \OCP\Settings\IManager
1864
+     */
1865
+    public function getSettingsManager() {
1866
+        return $this->query('SettingsManager');
1867
+    }
1868
+
1869
+    /**
1870
+     * @return \OCP\Files\IAppData
1871
+     */
1872
+    public function getAppDataDir($app) {
1873
+        /** @var \OC\Files\AppData\Factory $factory */
1874
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1875
+        return $factory->get($app);
1876
+    }
1877
+
1878
+    /**
1879
+     * @return \OCP\Lockdown\ILockdownManager
1880
+     */
1881
+    public function getLockdownManager() {
1882
+        return $this->query('LockdownManager');
1883
+    }
1884
+
1885
+    /**
1886
+     * @return \OCP\Federation\ICloudIdManager
1887
+     */
1888
+    public function getCloudIdManager() {
1889
+        return $this->query(ICloudIdManager::class);
1890
+    }
1891 1891
 }
Please login to merge, or discard this patch.