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