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