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