Server.php 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  5. *
  6. * @author Arne Hamann <kontakt+github@arne.email>
  7. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  8. * @author Bart Visscher <bartv@thisnet.nl>
  9. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  10. * @author Bernhard Reiter <ockham@raz.or.at>
  11. * @author Bjoern Schiessle <bjoern@schiessle.org>
  12. * @author Björn Schießle <bjoern@schiessle.org>
  13. * @author Christopher Schäpers <kondou@ts.unde.re>
  14. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  15. * @author Damjan Georgievski <gdamjan@gmail.com>
  16. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  17. * @author Georg Ehrke <oc.list@georgehrke.com>
  18. * @author Joas Schilling <coding@schilljs.com>
  19. * @author John Molakvoæ <skjnldsv@protonmail.com>
  20. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  21. * @author Julius Haertl <jus@bitgrid.net>
  22. * @author Julius Härtl <jus@bitgrid.net>
  23. * @author Lionel Elie Mamane <lionel@mamane.lu>
  24. * @author Lukas Reschke <lukas@statuscode.ch>
  25. * @author Maxence Lange <maxence@artificial-owl.com>
  26. * @author Michael Weimann <mail@michael-weimann.eu>
  27. * @author Morris Jobke <hey@morrisjobke.de>
  28. * @author Piotr Mrówczyński <mrow4a@yahoo.com>
  29. * @author Robin Appelman <robin@icewind.nl>
  30. * @author Robin McCorkell <robin@mccorkell.me.uk>
  31. * @author Roeland Jago Douma <roeland@famdouma.nl>
  32. * @author root <root@localhost.localdomain>
  33. * @author Thomas Müller <thomas.mueller@tmit.eu>
  34. * @author Thomas Tanghus <thomas@tanghus.net>
  35. * @author Tobia De Koninck <tobia@ledfan.be>
  36. * @author Vincent Petry <vincent@nextcloud.com>
  37. *
  38. * @license AGPL-3.0
  39. *
  40. * This code is free software: you can redistribute it and/or modify
  41. * it under the terms of the GNU Affero General Public License, version 3,
  42. * as published by the Free Software Foundation.
  43. *
  44. * This program is distributed in the hope that it will be useful,
  45. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  46. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  47. * GNU Affero General Public License for more details.
  48. *
  49. * You should have received a copy of the GNU Affero General Public License, version 3,
  50. * along with this program. If not, see <http://www.gnu.org/licenses/>
  51. *
  52. */
  53. namespace OC;
  54. use bantu\IniGetWrapper\IniGetWrapper;
  55. use OC\Accounts\AccountManager;
  56. use OC\App\AppManager;
  57. use OC\App\AppStore\Bundles\BundleFetcher;
  58. use OC\App\AppStore\Fetcher\AppFetcher;
  59. use OC\App\AppStore\Fetcher\CategoryFetcher;
  60. use OC\AppFramework\Bootstrap\Coordinator;
  61. use OC\AppFramework\Http\Request;
  62. use OC\AppFramework\Http\RequestId;
  63. use OC\AppFramework\Utility\TimeFactory;
  64. use OC\Authentication\Events\LoginFailed;
  65. use OC\Authentication\Listeners\LoginFailedListener;
  66. use OC\Authentication\Listeners\UserLoggedInListener;
  67. use OC\Authentication\LoginCredentials\Store;
  68. use OC\Authentication\Token\IProvider;
  69. use OC\Avatar\AvatarManager;
  70. use OC\Blurhash\Listener\GenerateBlurhashMetadata;
  71. use OC\Collaboration\Collaborators\GroupPlugin;
  72. use OC\Collaboration\Collaborators\MailPlugin;
  73. use OC\Collaboration\Collaborators\RemoteGroupPlugin;
  74. use OC\Collaboration\Collaborators\RemotePlugin;
  75. use OC\Collaboration\Collaborators\UserPlugin;
  76. use OC\Collaboration\Reference\ReferenceManager;
  77. use OC\Command\CronBus;
  78. use OC\Comments\ManagerFactory as CommentsManagerFactory;
  79. use OC\Contacts\ContactsMenu\ActionFactory;
  80. use OC\Contacts\ContactsMenu\ContactsStore;
  81. use OC\DB\Connection;
  82. use OC\DB\ConnectionAdapter;
  83. use OC\Diagnostics\EventLogger;
  84. use OC\Diagnostics\QueryLogger;
  85. use OC\Federation\CloudFederationFactory;
  86. use OC\Federation\CloudFederationProviderManager;
  87. use OC\Federation\CloudIdManager;
  88. use OC\Files\Config\MountProviderCollection;
  89. use OC\Files\Config\UserMountCache;
  90. use OC\Files\Config\UserMountCacheListener;
  91. use OC\Files\Lock\LockManager;
  92. use OC\Files\Mount\CacheMountProvider;
  93. use OC\Files\Mount\LocalHomeMountProvider;
  94. use OC\Files\Mount\ObjectHomeMountProvider;
  95. use OC\Files\Mount\ObjectStorePreviewCacheMountProvider;
  96. use OC\Files\Mount\RootMountProvider;
  97. use OC\Files\Node\HookConnector;
  98. use OC\Files\Node\LazyRoot;
  99. use OC\Files\Node\Root;
  100. use OC\Files\SetupManager;
  101. use OC\Files\Storage\StorageFactory;
  102. use OC\Files\Template\TemplateManager;
  103. use OC\Files\Type\Loader;
  104. use OC\Files\View;
  105. use OC\FilesMetadata\FilesMetadataManager;
  106. use OC\FullTextSearch\FullTextSearchManager;
  107. use OC\Http\Client\ClientService;
  108. use OC\Http\Client\NegativeDnsCache;
  109. use OC\IntegrityCheck\Checker;
  110. use OC\IntegrityCheck\Helpers\AppLocator;
  111. use OC\IntegrityCheck\Helpers\EnvironmentHelper;
  112. use OC\IntegrityCheck\Helpers\FileAccessHelper;
  113. use OC\KnownUser\KnownUserService;
  114. use OC\LDAP\NullLDAPProviderFactory;
  115. use OC\Lock\DBLockingProvider;
  116. use OC\Lock\MemcacheLockingProvider;
  117. use OC\Lock\NoopLockingProvider;
  118. use OC\Lockdown\LockdownManager;
  119. use OC\Log\LogFactory;
  120. use OC\Log\PsrLoggerAdapter;
  121. use OC\Mail\Mailer;
  122. use OC\Memcache\ArrayCache;
  123. use OC\Memcache\Factory;
  124. use OC\Notification\Manager;
  125. use OC\OCM\Model\OCMProvider;
  126. use OC\OCM\OCMDiscoveryService;
  127. use OC\OCS\DiscoveryService;
  128. use OC\Preview\GeneratorHelper;
  129. use OC\Preview\IMagickSupport;
  130. use OC\Preview\MimeIconProvider;
  131. use OC\Profile\ProfileManager;
  132. use OC\Profiler\Profiler;
  133. use OC\Remote\Api\ApiFactory;
  134. use OC\Remote\InstanceFactory;
  135. use OC\RichObjectStrings\Validator;
  136. use OC\Route\CachingRouter;
  137. use OC\Route\Router;
  138. use OC\Security\Bruteforce\Throttler;
  139. use OC\Security\CertificateManager;
  140. use OC\Security\CredentialsManager;
  141. use OC\Security\Crypto;
  142. use OC\Security\CSP\ContentSecurityPolicyManager;
  143. use OC\Security\CSP\ContentSecurityPolicyNonceManager;
  144. use OC\Security\CSRF\CsrfTokenManager;
  145. use OC\Security\CSRF\TokenStorage\SessionStorage;
  146. use OC\Security\Hasher;
  147. use OC\Security\RateLimiting\Limiter;
  148. use OC\Security\SecureRandom;
  149. use OC\Security\TrustedDomainHelper;
  150. use OC\Security\VerificationToken\VerificationToken;
  151. use OC\Session\CryptoWrapper;
  152. use OC\Settings\DeclarativeManager;
  153. use OC\SetupCheck\SetupCheckManager;
  154. use OC\Share20\ProviderFactory;
  155. use OC\Share20\ShareHelper;
  156. use OC\SpeechToText\SpeechToTextManager;
  157. use OC\SystemTag\ManagerFactory as SystemTagManagerFactory;
  158. use OC\Tagging\TagMapper;
  159. use OC\Talk\Broker;
  160. use OC\Teams\TeamManager;
  161. use OC\Template\JSCombiner;
  162. use OC\Translation\TranslationManager;
  163. use OC\User\AvailabilityCoordinator;
  164. use OC\User\DisplayNameCache;
  165. use OC\User\Listeners\BeforeUserDeletedListener;
  166. use OC\User\Listeners\UserChangedListener;
  167. use OC\User\Session;
  168. use OCA\Files_External\Service\BackendService;
  169. use OCA\Files_External\Service\GlobalStoragesService;
  170. use OCA\Files_External\Service\UserGlobalStoragesService;
  171. use OCA\Files_External\Service\UserStoragesService;
  172. use OCA\Theming\ImageManager;
  173. use OCA\Theming\Service\BackgroundService;
  174. use OCA\Theming\ThemingDefaults;
  175. use OCA\Theming\Util;
  176. use OCP\Accounts\IAccountManager;
  177. use OCP\App\IAppManager;
  178. use OCP\AppFramework\Utility\ITimeFactory;
  179. use OCP\Authentication\LoginCredentials\IStore;
  180. use OCP\Authentication\Token\IProvider as OCPIProvider;
  181. use OCP\BackgroundJob\IJobList;
  182. use OCP\Collaboration\AutoComplete\IManager;
  183. use OCP\Collaboration\Reference\IReferenceManager;
  184. use OCP\Command\IBus;
  185. use OCP\Comments\ICommentsManager;
  186. use OCP\Contacts\ContactsMenu\IActionFactory;
  187. use OCP\Contacts\ContactsMenu\IContactsStore;
  188. use OCP\Defaults;
  189. use OCP\Diagnostics\IEventLogger;
  190. use OCP\Diagnostics\IQueryLogger;
  191. use OCP\Encryption\IFile;
  192. use OCP\Encryption\Keys\IStorage;
  193. use OCP\EventDispatcher\IEventDispatcher;
  194. use OCP\Federation\ICloudFederationFactory;
  195. use OCP\Federation\ICloudFederationProviderManager;
  196. use OCP\Federation\ICloudIdManager;
  197. use OCP\Files\Config\IMountProviderCollection;
  198. use OCP\Files\Config\IUserMountCache;
  199. use OCP\Files\IMimeTypeDetector;
  200. use OCP\Files\IMimeTypeLoader;
  201. use OCP\Files\IRootFolder;
  202. use OCP\Files\Lock\ILockManager;
  203. use OCP\Files\Mount\IMountManager;
  204. use OCP\Files\Storage\IStorageFactory;
  205. use OCP\Files\Template\ITemplateManager;
  206. use OCP\FilesMetadata\IFilesMetadataManager;
  207. use OCP\FullTextSearch\IFullTextSearchManager;
  208. use OCP\GlobalScale\IConfig;
  209. use OCP\Group\ISubAdmin;
  210. use OCP\Http\Client\IClientService;
  211. use OCP\IAppConfig;
  212. use OCP\IAvatarManager;
  213. use OCP\IBinaryFinder;
  214. use OCP\ICache;
  215. use OCP\ICacheFactory;
  216. use OCP\ICertificateManager;
  217. use OCP\IDateTimeFormatter;
  218. use OCP\IDateTimeZone;
  219. use OCP\IDBConnection;
  220. use OCP\IEventSourceFactory;
  221. use OCP\IGroupManager;
  222. use OCP\IInitialStateService;
  223. use OCP\IL10N;
  224. use OCP\ILogger;
  225. use OCP\INavigationManager;
  226. use OCP\IPhoneNumberUtil;
  227. use OCP\IPreview;
  228. use OCP\IRequest;
  229. use OCP\IRequestId;
  230. use OCP\ISearch;
  231. use OCP\IServerContainer;
  232. use OCP\ISession;
  233. use OCP\ITagManager;
  234. use OCP\ITempManager;
  235. use OCP\IURLGenerator;
  236. use OCP\IUserManager;
  237. use OCP\IUserSession;
  238. use OCP\L10N\IFactory;
  239. use OCP\LDAP\ILDAPProvider;
  240. use OCP\LDAP\ILDAPProviderFactory;
  241. use OCP\Lock\ILockingProvider;
  242. use OCP\Lockdown\ILockdownManager;
  243. use OCP\Log\ILogFactory;
  244. use OCP\Mail\IMailer;
  245. use OCP\OCM\IOCMDiscoveryService;
  246. use OCP\OCM\IOCMProvider;
  247. use OCP\Preview\IMimeIconProvider;
  248. use OCP\Profile\IProfileManager;
  249. use OCP\Profiler\IProfiler;
  250. use OCP\Remote\Api\IApiFactory;
  251. use OCP\Remote\IInstanceFactory;
  252. use OCP\RichObjectStrings\IValidator;
  253. use OCP\Route\IRouter;
  254. use OCP\Security\Bruteforce\IThrottler;
  255. use OCP\Security\IContentSecurityPolicyManager;
  256. use OCP\Security\ICredentialsManager;
  257. use OCP\Security\ICrypto;
  258. use OCP\Security\IHasher;
  259. use OCP\Security\ISecureRandom;
  260. use OCP\Security\ITrustedDomainHelper;
  261. use OCP\Security\RateLimiting\ILimiter;
  262. use OCP\Security\VerificationToken\IVerificationToken;
  263. use OCP\Settings\IDeclarativeManager;
  264. use OCP\SetupCheck\ISetupCheckManager;
  265. use OCP\Share\IProviderFactory;
  266. use OCP\Share\IShareHelper;
  267. use OCP\SpeechToText\ISpeechToTextManager;
  268. use OCP\SystemTag\ISystemTagManager;
  269. use OCP\SystemTag\ISystemTagObjectMapper;
  270. use OCP\Talk\IBroker;
  271. use OCP\Teams\ITeamManager;
  272. use OCP\Translation\ITranslationManager;
  273. use OCP\User\Events\BeforeUserDeletedEvent;
  274. use OCP\User\Events\BeforeUserLoggedInEvent;
  275. use OCP\User\Events\BeforeUserLoggedInWithCookieEvent;
  276. use OCP\User\Events\BeforeUserLoggedOutEvent;
  277. use OCP\User\Events\PostLoginEvent;
  278. use OCP\User\Events\UserChangedEvent;
  279. use OCP\User\Events\UserLoggedInEvent;
  280. use OCP\User\Events\UserLoggedInWithCookieEvent;
  281. use OCP\User\Events\UserLoggedOutEvent;
  282. use OCP\User\IAvailabilityCoordinator;
  283. use Psr\Container\ContainerExceptionInterface;
  284. use Psr\Container\ContainerInterface;
  285. use Psr\Log\LoggerInterface;
  286. /**
  287. * Class Server
  288. *
  289. * @package OC
  290. *
  291. * TODO: hookup all manager classes
  292. */
  293. class Server extends ServerContainer implements IServerContainer {
  294. /** @var string */
  295. private $webRoot;
  296. /**
  297. * @param string $webRoot
  298. * @param \OC\Config $config
  299. */
  300. public function __construct($webRoot, \OC\Config $config) {
  301. parent::__construct();
  302. $this->webRoot = $webRoot;
  303. // To find out if we are running from CLI or not
  304. $this->registerParameter('isCLI', \OC::$CLI);
  305. $this->registerParameter('serverRoot', \OC::$SERVERROOT);
  306. $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
  307. return $c;
  308. });
  309. $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
  310. return $c;
  311. });
  312. $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
  313. /** @deprecated 19.0.0 */
  314. $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
  315. $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
  316. /** @deprecated 19.0.0 */
  317. $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
  318. $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
  319. /** @deprecated 19.0.0 */
  320. $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
  321. $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
  322. /** @deprecated 19.0.0 */
  323. $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
  324. $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
  325. $this->registerAlias(ITemplateManager::class, TemplateManager::class);
  326. $this->registerAlias(IActionFactory::class, ActionFactory::class);
  327. $this->registerService(View::class, function (Server $c) {
  328. return new View();
  329. }, false);
  330. $this->registerService(IPreview::class, function (ContainerInterface $c) {
  331. return new PreviewManager(
  332. $c->get(\OCP\IConfig::class),
  333. $c->get(IRootFolder::class),
  334. new \OC\Preview\Storage\Root(
  335. $c->get(IRootFolder::class),
  336. $c->get(SystemConfig::class)
  337. ),
  338. $c->get(IEventDispatcher::class),
  339. $c->get(GeneratorHelper::class),
  340. $c->get(ISession::class)->get('user_id'),
  341. $c->get(Coordinator::class),
  342. $c->get(IServerContainer::class),
  343. $c->get(IBinaryFinder::class),
  344. $c->get(IMagickSupport::class)
  345. );
  346. });
  347. /** @deprecated 19.0.0 */
  348. $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
  349. $this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
  350. $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
  351. return new \OC\Preview\Watcher(
  352. new \OC\Preview\Storage\Root(
  353. $c->get(IRootFolder::class),
  354. $c->get(SystemConfig::class)
  355. )
  356. );
  357. });
  358. $this->registerService(IProfiler::class, function (Server $c) {
  359. return new Profiler($c->get(SystemConfig::class));
  360. });
  361. $this->registerService(\OCP\Encryption\IManager::class, function (Server $c): Encryption\Manager {
  362. $view = new View();
  363. $util = new Encryption\Util(
  364. $view,
  365. $c->get(IUserManager::class),
  366. $c->get(IGroupManager::class),
  367. $c->get(\OCP\IConfig::class)
  368. );
  369. return new Encryption\Manager(
  370. $c->get(\OCP\IConfig::class),
  371. $c->get(LoggerInterface::class),
  372. $c->getL10N('core'),
  373. new View(),
  374. $util,
  375. new ArrayCache()
  376. );
  377. });
  378. /** @deprecated 19.0.0 */
  379. $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
  380. /** @deprecated 21.0.0 */
  381. $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
  382. $this->registerService(IFile::class, function (ContainerInterface $c) {
  383. $util = new Encryption\Util(
  384. new View(),
  385. $c->get(IUserManager::class),
  386. $c->get(IGroupManager::class),
  387. $c->get(\OCP\IConfig::class)
  388. );
  389. return new Encryption\File(
  390. $util,
  391. $c->get(IRootFolder::class),
  392. $c->get(\OCP\Share\IManager::class)
  393. );
  394. });
  395. /** @deprecated 21.0.0 */
  396. $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
  397. $this->registerService(IStorage::class, function (ContainerInterface $c) {
  398. $view = new View();
  399. $util = new Encryption\Util(
  400. $view,
  401. $c->get(IUserManager::class),
  402. $c->get(IGroupManager::class),
  403. $c->get(\OCP\IConfig::class)
  404. );
  405. return new Encryption\Keys\Storage(
  406. $view,
  407. $util,
  408. $c->get(ICrypto::class),
  409. $c->get(\OCP\IConfig::class)
  410. );
  411. });
  412. /** @deprecated 20.0.0 */
  413. $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
  414. $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
  415. /** @deprecated 19.0.0 */
  416. $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
  417. $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
  418. /** @var \OCP\IConfig $config */
  419. $config = $c->get(\OCP\IConfig::class);
  420. $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
  421. return new $factoryClass($this);
  422. });
  423. $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
  424. return $c->get('SystemTagManagerFactory')->getManager();
  425. });
  426. /** @deprecated 19.0.0 */
  427. $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
  428. $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
  429. return $c->get('SystemTagManagerFactory')->getObjectMapper();
  430. });
  431. $this->registerService('RootFolder', function (ContainerInterface $c) {
  432. $manager = \OC\Files\Filesystem::getMountManager();
  433. $view = new View();
  434. /** @var IUserSession $userSession */
  435. $userSession = $c->get(IUserSession::class);
  436. $root = new Root(
  437. $manager,
  438. $view,
  439. $userSession->getUser(),
  440. $c->get(IUserMountCache::class),
  441. $this->get(LoggerInterface::class),
  442. $this->get(IUserManager::class),
  443. $this->get(IEventDispatcher::class),
  444. $this->get(ICacheFactory::class),
  445. );
  446. $previewConnector = new \OC\Preview\WatcherConnector(
  447. $root,
  448. $c->get(SystemConfig::class)
  449. );
  450. $previewConnector->connectWatcher();
  451. return $root;
  452. });
  453. $this->registerService(HookConnector::class, function (ContainerInterface $c) {
  454. return new HookConnector(
  455. $c->get(IRootFolder::class),
  456. new View(),
  457. $c->get(IEventDispatcher::class),
  458. $c->get(LoggerInterface::class)
  459. );
  460. });
  461. /** @deprecated 19.0.0 */
  462. $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
  463. $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
  464. return new LazyRoot(function () use ($c) {
  465. return $c->get('RootFolder');
  466. });
  467. });
  468. /** @deprecated 19.0.0 */
  469. $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
  470. /** @deprecated 19.0.0 */
  471. $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
  472. $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
  473. $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
  474. return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
  475. });
  476. $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
  477. $groupManager = new \OC\Group\Manager(
  478. $this->get(IUserManager::class),
  479. $this->get(IEventDispatcher::class),
  480. $this->get(LoggerInterface::class),
  481. $this->get(ICacheFactory::class)
  482. );
  483. return $groupManager;
  484. });
  485. /** @deprecated 19.0.0 */
  486. $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
  487. $this->registerService(Store::class, function (ContainerInterface $c) {
  488. $session = $c->get(ISession::class);
  489. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  490. $tokenProvider = $c->get(IProvider::class);
  491. } else {
  492. $tokenProvider = null;
  493. }
  494. $logger = $c->get(LoggerInterface::class);
  495. return new Store($session, $logger, $tokenProvider);
  496. });
  497. $this->registerAlias(IStore::class, Store::class);
  498. $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
  499. $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
  500. $this->registerService(\OC\User\Session::class, function (Server $c) {
  501. $manager = $c->get(IUserManager::class);
  502. $session = new \OC\Session\Memory('');
  503. $timeFactory = new TimeFactory();
  504. // Token providers might require a working database. This code
  505. // might however be called when Nextcloud is not yet setup.
  506. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  507. $provider = $c->get(IProvider::class);
  508. } else {
  509. $provider = null;
  510. }
  511. $userSession = new \OC\User\Session(
  512. $manager,
  513. $session,
  514. $timeFactory,
  515. $provider,
  516. $c->get(\OCP\IConfig::class),
  517. $c->get(ISecureRandom::class),
  518. $c->get('LockdownManager'),
  519. $c->get(LoggerInterface::class),
  520. $c->get(IEventDispatcher::class)
  521. );
  522. /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
  523. $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
  524. \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
  525. });
  526. /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
  527. $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
  528. /** @var \OC\User\User $user */
  529. \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
  530. });
  531. /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
  532. $userSession->listen('\OC\User', 'preDelete', function ($user) {
  533. /** @var \OC\User\User $user */
  534. \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
  535. });
  536. /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
  537. $userSession->listen('\OC\User', 'postDelete', function ($user) {
  538. /** @var \OC\User\User $user */
  539. \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
  540. });
  541. $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
  542. /** @var \OC\User\User $user */
  543. \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  544. });
  545. $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
  546. /** @var \OC\User\User $user */
  547. \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  548. });
  549. $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
  550. \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
  551. /** @var IEventDispatcher $dispatcher */
  552. $dispatcher = $this->get(IEventDispatcher::class);
  553. $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
  554. });
  555. $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
  556. /** @var \OC\User\User $user */
  557. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
  558. /** @var IEventDispatcher $dispatcher */
  559. $dispatcher = $this->get(IEventDispatcher::class);
  560. $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
  561. });
  562. $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
  563. /** @var IEventDispatcher $dispatcher */
  564. $dispatcher = $this->get(IEventDispatcher::class);
  565. $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
  566. });
  567. $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
  568. /** @var \OC\User\User $user */
  569. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
  570. /** @var IEventDispatcher $dispatcher */
  571. $dispatcher = $this->get(IEventDispatcher::class);
  572. $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
  573. });
  574. $userSession->listen('\OC\User', 'logout', function ($user) {
  575. \OC_Hook::emit('OC_User', 'logout', []);
  576. /** @var IEventDispatcher $dispatcher */
  577. $dispatcher = $this->get(IEventDispatcher::class);
  578. $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
  579. });
  580. $userSession->listen('\OC\User', 'postLogout', function ($user) {
  581. /** @var IEventDispatcher $dispatcher */
  582. $dispatcher = $this->get(IEventDispatcher::class);
  583. $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
  584. });
  585. $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
  586. /** @var \OC\User\User $user */
  587. \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
  588. });
  589. return $userSession;
  590. });
  591. $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
  592. /** @deprecated 19.0.0 */
  593. $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
  594. $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
  595. $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
  596. /** @deprecated 19.0.0 */
  597. $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
  598. /** @deprecated 19.0.0 */
  599. $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
  600. $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
  601. $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
  602. return new \OC\SystemConfig($config);
  603. });
  604. /** @deprecated 19.0.0 */
  605. $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
  606. /** @deprecated 19.0.0 */
  607. $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
  608. $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
  609. $this->registerService(IFactory::class, function (Server $c) {
  610. return new \OC\L10N\Factory(
  611. $c->get(\OCP\IConfig::class),
  612. $c->getRequest(),
  613. $c->get(IUserSession::class),
  614. $c->get(ICacheFactory::class),
  615. \OC::$SERVERROOT,
  616. $c->get(IAppManager::class),
  617. );
  618. });
  619. /** @deprecated 19.0.0 */
  620. $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
  621. $this->registerAlias(IURLGenerator::class, URLGenerator::class);
  622. /** @deprecated 19.0.0 */
  623. $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
  624. /** @deprecated 19.0.0 */
  625. $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
  626. /** @deprecated 19.0.0 */
  627. $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
  628. $this->registerService(ICache::class, function ($c) {
  629. return new Cache\File();
  630. });
  631. /** @deprecated 19.0.0 */
  632. $this->registerDeprecatedAlias('UserCache', ICache::class);
  633. $this->registerService(Factory::class, function (Server $c) {
  634. $profiler = $c->get(IProfiler::class);
  635. $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(LoggerInterface::class),
  636. $profiler,
  637. ArrayCache::class,
  638. ArrayCache::class,
  639. ArrayCache::class
  640. );
  641. /** @var \OCP\IConfig $config */
  642. $config = $c->get(\OCP\IConfig::class);
  643. if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  644. if (!$config->getSystemValueBool('log_query')) {
  645. try {
  646. $v = \OC_App::getAppVersions();
  647. } catch (\Doctrine\DBAL\Exception $e) {
  648. // Database service probably unavailable
  649. // Probably related to https://github.com/nextcloud/server/issues/37424
  650. return $arrayCacheFactory;
  651. }
  652. } else {
  653. // If the log_query is enabled, we can not get the app versions
  654. // as that does a query, which will be logged and the logging
  655. // depends on redis and here we are back again in the same function.
  656. $v = [
  657. 'log_query' => 'enabled',
  658. ];
  659. }
  660. $v['core'] = implode(',', \OC_Util::getVersion());
  661. $version = implode(',', $v);
  662. $instanceId = \OC_Util::getInstanceId();
  663. $path = \OC::$SERVERROOT;
  664. $prefix = md5($instanceId . '-' . $version . '-' . $path);
  665. return new \OC\Memcache\Factory($prefix,
  666. $c->get(LoggerInterface::class),
  667. $profiler,
  668. $config->getSystemValue('memcache.local', null),
  669. $config->getSystemValue('memcache.distributed', null),
  670. $config->getSystemValue('memcache.locking', null),
  671. $config->getSystemValueString('redis_log_file')
  672. );
  673. }
  674. return $arrayCacheFactory;
  675. });
  676. /** @deprecated 19.0.0 */
  677. $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
  678. $this->registerAlias(ICacheFactory::class, Factory::class);
  679. $this->registerService('RedisFactory', function (Server $c) {
  680. $systemConfig = $c->get(SystemConfig::class);
  681. return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
  682. });
  683. $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
  684. $l10n = $this->get(IFactory::class)->get('lib');
  685. return new \OC\Activity\Manager(
  686. $c->getRequest(),
  687. $c->get(IUserSession::class),
  688. $c->get(\OCP\IConfig::class),
  689. $c->get(IValidator::class),
  690. $l10n
  691. );
  692. });
  693. /** @deprecated 19.0.0 */
  694. $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
  695. $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
  696. return new \OC\Activity\EventMerger(
  697. $c->getL10N('lib')
  698. );
  699. });
  700. $this->registerAlias(IValidator::class, Validator::class);
  701. $this->registerService(AvatarManager::class, function (Server $c) {
  702. return new AvatarManager(
  703. $c->get(IUserSession::class),
  704. $c->get(\OC\User\Manager::class),
  705. $c->getAppDataDir('avatar'),
  706. $c->getL10N('lib'),
  707. $c->get(LoggerInterface::class),
  708. $c->get(\OCP\IConfig::class),
  709. $c->get(IAccountManager::class),
  710. $c->get(KnownUserService::class)
  711. );
  712. });
  713. $this->registerAlias(IAvatarManager::class, AvatarManager::class);
  714. /** @deprecated 19.0.0 */
  715. $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
  716. $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
  717. $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
  718. $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
  719. $this->registerService(\OC\Log::class, function (Server $c) {
  720. $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
  721. $factory = new LogFactory($c, $this->get(SystemConfig::class));
  722. $logger = $factory->get($logType);
  723. $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
  724. return new Log($logger, $this->get(SystemConfig::class), null, $registry);
  725. });
  726. $this->registerAlias(ILogger::class, \OC\Log::class);
  727. /** @deprecated 19.0.0 */
  728. $this->registerDeprecatedAlias('Logger', \OC\Log::class);
  729. // PSR-3 logger
  730. $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
  731. $this->registerService(ILogFactory::class, function (Server $c) {
  732. return new LogFactory($c, $this->get(SystemConfig::class));
  733. });
  734. $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
  735. /** @deprecated 19.0.0 */
  736. $this->registerDeprecatedAlias('JobList', IJobList::class);
  737. $this->registerService(Router::class, function (Server $c) {
  738. $cacheFactory = $c->get(ICacheFactory::class);
  739. if ($cacheFactory->isLocalCacheAvailable()) {
  740. $router = $c->resolve(CachingRouter::class);
  741. } else {
  742. $router = $c->resolve(Router::class);
  743. }
  744. return $router;
  745. });
  746. $this->registerAlias(IRouter::class, Router::class);
  747. /** @deprecated 19.0.0 */
  748. $this->registerDeprecatedAlias('Router', IRouter::class);
  749. $this->registerAlias(ISearch::class, Search::class);
  750. /** @deprecated 19.0.0 */
  751. $this->registerDeprecatedAlias('Search', ISearch::class);
  752. $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
  753. $config = $c->get(\OCP\IConfig::class);
  754. if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
  755. $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
  756. $c->get(AllConfig::class),
  757. $this->get(ICacheFactory::class),
  758. new \OC\AppFramework\Utility\TimeFactory()
  759. );
  760. } else {
  761. $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
  762. $c->get(AllConfig::class),
  763. $c->get(IDBConnection::class),
  764. new \OC\AppFramework\Utility\TimeFactory()
  765. );
  766. }
  767. return $backend;
  768. });
  769. $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
  770. /** @deprecated 19.0.0 */
  771. $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
  772. $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
  773. $this->registerAlias(IVerificationToken::class, VerificationToken::class);
  774. $this->registerAlias(ICrypto::class, Crypto::class);
  775. /** @deprecated 19.0.0 */
  776. $this->registerDeprecatedAlias('Crypto', ICrypto::class);
  777. $this->registerAlias(IHasher::class, Hasher::class);
  778. /** @deprecated 19.0.0 */
  779. $this->registerDeprecatedAlias('Hasher', IHasher::class);
  780. $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
  781. /** @deprecated 19.0.0 */
  782. $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
  783. $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
  784. $this->registerService(Connection::class, function (Server $c) {
  785. $systemConfig = $c->get(SystemConfig::class);
  786. $factory = new \OC\DB\ConnectionFactory($systemConfig);
  787. $type = $systemConfig->getValue('dbtype', 'sqlite');
  788. if (!$factory->isValidType($type)) {
  789. throw new \OC\DatabaseException('Invalid database type');
  790. }
  791. $connection = $factory->getConnection($type, []);
  792. return $connection;
  793. });
  794. /** @deprecated 19.0.0 */
  795. $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
  796. $this->registerAlias(ICertificateManager::class, CertificateManager::class);
  797. $this->registerAlias(IClientService::class, ClientService::class);
  798. $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
  799. return new NegativeDnsCache(
  800. $c->get(ICacheFactory::class),
  801. );
  802. });
  803. $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
  804. $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
  805. return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
  806. });
  807. /** @deprecated 19.0.0 */
  808. $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
  809. $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
  810. $queryLogger = new QueryLogger();
  811. if ($c->get(SystemConfig::class)->getValue('debug', false)) {
  812. // In debug mode, module is being activated by default
  813. $queryLogger->activate();
  814. }
  815. return $queryLogger;
  816. });
  817. /** @deprecated 19.0.0 */
  818. $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
  819. /** @deprecated 19.0.0 */
  820. $this->registerDeprecatedAlias('TempManager', TempManager::class);
  821. $this->registerAlias(ITempManager::class, TempManager::class);
  822. $this->registerService(AppManager::class, function (ContainerInterface $c) {
  823. // TODO: use auto-wiring
  824. return new \OC\App\AppManager(
  825. $c->get(IUserSession::class),
  826. $c->get(\OCP\IConfig::class),
  827. $c->get(IGroupManager::class),
  828. $c->get(ICacheFactory::class),
  829. $c->get(IEventDispatcher::class),
  830. $c->get(LoggerInterface::class),
  831. );
  832. });
  833. /** @deprecated 19.0.0 */
  834. $this->registerDeprecatedAlias('AppManager', AppManager::class);
  835. $this->registerAlias(IAppManager::class, AppManager::class);
  836. $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
  837. /** @deprecated 19.0.0 */
  838. $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
  839. $this->registerService(IDateTimeFormatter::class, function (Server $c) {
  840. $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
  841. return new DateTimeFormatter(
  842. $c->get(IDateTimeZone::class)->getTimeZone(),
  843. $c->getL10N('lib', $language)
  844. );
  845. });
  846. /** @deprecated 19.0.0 */
  847. $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
  848. $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
  849. $mountCache = $c->get(UserMountCache::class);
  850. $listener = new UserMountCacheListener($mountCache);
  851. $listener->listen($c->get(IUserManager::class));
  852. return $mountCache;
  853. });
  854. /** @deprecated 19.0.0 */
  855. $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
  856. $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
  857. $loader = $c->get(IStorageFactory::class);
  858. $mountCache = $c->get(IUserMountCache::class);
  859. $eventLogger = $c->get(IEventLogger::class);
  860. $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
  861. // builtin providers
  862. $config = $c->get(\OCP\IConfig::class);
  863. $logger = $c->get(LoggerInterface::class);
  864. $manager->registerProvider(new CacheMountProvider($config));
  865. $manager->registerHomeProvider(new LocalHomeMountProvider());
  866. $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
  867. $manager->registerRootProvider(new RootMountProvider($config, $c->get(LoggerInterface::class)));
  868. $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
  869. return $manager;
  870. });
  871. /** @deprecated 19.0.0 */
  872. $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
  873. /** @deprecated 20.0.0 */
  874. $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
  875. $this->registerService(IBus::class, function (ContainerInterface $c) {
  876. $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
  877. if ($busClass) {
  878. [$app, $class] = explode('::', $busClass, 2);
  879. if ($c->get(IAppManager::class)->isInstalled($app)) {
  880. \OC_App::loadApp($app);
  881. return $c->get($class);
  882. } else {
  883. throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
  884. }
  885. } else {
  886. $jobList = $c->get(IJobList::class);
  887. return new CronBus($jobList);
  888. }
  889. });
  890. $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
  891. /** @deprecated 20.0.0 */
  892. $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
  893. $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
  894. /** @deprecated 19.0.0 */
  895. $this->registerDeprecatedAlias('Throttler', Throttler::class);
  896. $this->registerAlias(IThrottler::class, Throttler::class);
  897. $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
  898. $config = $c->get(\OCP\IConfig::class);
  899. if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
  900. $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
  901. } else {
  902. $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
  903. }
  904. return $backend;
  905. });
  906. $this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
  907. $this->registerService(Checker::class, function (ContainerInterface $c) {
  908. // IConfig and IAppManager requires a working database. This code
  909. // might however be called when ownCloud is not yet setup.
  910. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  911. $config = $c->get(\OCP\IConfig::class);
  912. $appConfig = $c->get(\OCP\IAppConfig::class);
  913. $appManager = $c->get(IAppManager::class);
  914. } else {
  915. $config = $appConfig = $appManager = null;
  916. }
  917. return new Checker(
  918. new EnvironmentHelper(),
  919. new FileAccessHelper(),
  920. new AppLocator(),
  921. $config,
  922. $appConfig,
  923. $c->get(ICacheFactory::class),
  924. $appManager,
  925. $c->get(IMimeTypeDetector::class)
  926. );
  927. });
  928. $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
  929. if (isset($this['urlParams'])) {
  930. $urlParams = $this['urlParams'];
  931. } else {
  932. $urlParams = [];
  933. }
  934. if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
  935. && in_array('fakeinput', stream_get_wrappers())
  936. ) {
  937. $stream = 'fakeinput://data';
  938. } else {
  939. $stream = 'php://input';
  940. }
  941. return new Request(
  942. [
  943. 'get' => $_GET,
  944. 'post' => $_POST,
  945. 'files' => $_FILES,
  946. 'server' => $_SERVER,
  947. 'env' => $_ENV,
  948. 'cookies' => $_COOKIE,
  949. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  950. ? $_SERVER['REQUEST_METHOD']
  951. : '',
  952. 'urlParams' => $urlParams,
  953. ],
  954. $this->get(IRequestId::class),
  955. $this->get(\OCP\IConfig::class),
  956. $this->get(CsrfTokenManager::class),
  957. $stream
  958. );
  959. });
  960. /** @deprecated 19.0.0 */
  961. $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
  962. $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
  963. return new RequestId(
  964. $_SERVER['UNIQUE_ID'] ?? '',
  965. $this->get(ISecureRandom::class)
  966. );
  967. });
  968. $this->registerService(IMailer::class, function (Server $c) {
  969. return new Mailer(
  970. $c->get(\OCP\IConfig::class),
  971. $c->get(LoggerInterface::class),
  972. $c->get(Defaults::class),
  973. $c->get(IURLGenerator::class),
  974. $c->getL10N('lib'),
  975. $c->get(IEventDispatcher::class),
  976. $c->get(IFactory::class)
  977. );
  978. });
  979. /** @deprecated 19.0.0 */
  980. $this->registerDeprecatedAlias('Mailer', IMailer::class);
  981. /** @deprecated 21.0.0 */
  982. $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
  983. $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
  984. $config = $c->get(\OCP\IConfig::class);
  985. $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
  986. if (is_null($factoryClass) || !class_exists($factoryClass)) {
  987. return new NullLDAPProviderFactory($this);
  988. }
  989. /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
  990. return new $factoryClass($this);
  991. });
  992. $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
  993. $factory = $c->get(ILDAPProviderFactory::class);
  994. return $factory->getLDAPProvider();
  995. });
  996. $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
  997. $ini = $c->get(IniGetWrapper::class);
  998. $config = $c->get(\OCP\IConfig::class);
  999. $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
  1000. if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  1001. /** @var \OC\Memcache\Factory $memcacheFactory */
  1002. $memcacheFactory = $c->get(ICacheFactory::class);
  1003. $memcache = $memcacheFactory->createLocking('lock');
  1004. if (!($memcache instanceof \OC\Memcache\NullCache)) {
  1005. $timeFactory = $c->get(ITimeFactory::class);
  1006. return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
  1007. }
  1008. return new DBLockingProvider(
  1009. $c->get(IDBConnection::class),
  1010. new TimeFactory(),
  1011. $ttl,
  1012. !\OC::$CLI
  1013. );
  1014. }
  1015. return new NoopLockingProvider();
  1016. });
  1017. /** @deprecated 19.0.0 */
  1018. $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
  1019. $this->registerService(ILockManager::class, function (Server $c): LockManager {
  1020. return new LockManager();
  1021. });
  1022. $this->registerAlias(ILockdownManager::class, 'LockdownManager');
  1023. $this->registerService(SetupManager::class, function ($c) {
  1024. // create the setupmanager through the mount manager to resolve the cyclic dependency
  1025. return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
  1026. });
  1027. $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
  1028. /** @deprecated 19.0.0 */
  1029. $this->registerDeprecatedAlias('MountManager', IMountManager::class);
  1030. $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
  1031. return new \OC\Files\Type\Detection(
  1032. $c->get(IURLGenerator::class),
  1033. $c->get(LoggerInterface::class),
  1034. \OC::$configDir,
  1035. \OC::$SERVERROOT . '/resources/config/'
  1036. );
  1037. });
  1038. /** @deprecated 19.0.0 */
  1039. $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
  1040. $this->registerAlias(IMimeTypeLoader::class, Loader::class);
  1041. /** @deprecated 19.0.0 */
  1042. $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
  1043. $this->registerService(BundleFetcher::class, function () {
  1044. return new BundleFetcher($this->getL10N('lib'));
  1045. });
  1046. $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
  1047. /** @deprecated 19.0.0 */
  1048. $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
  1049. $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
  1050. $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
  1051. $manager->registerCapability(function () use ($c) {
  1052. return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
  1053. });
  1054. $manager->registerCapability(function () use ($c) {
  1055. return $c->get(\OC\Security\Bruteforce\Capabilities::class);
  1056. });
  1057. return $manager;
  1058. });
  1059. /** @deprecated 19.0.0 */
  1060. $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
  1061. $this->registerService(ICommentsManager::class, function (Server $c) {
  1062. $config = $c->get(\OCP\IConfig::class);
  1063. $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
  1064. /** @var \OCP\Comments\ICommentsManagerFactory $factory */
  1065. $factory = new $factoryClass($this);
  1066. $manager = $factory->getManager();
  1067. $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
  1068. $manager = $c->get(IUserManager::class);
  1069. $userDisplayName = $manager->getDisplayName($id);
  1070. if ($userDisplayName === null) {
  1071. $l = $c->get(IFactory::class)->get('core');
  1072. return $l->t('Unknown account');
  1073. }
  1074. return $userDisplayName;
  1075. });
  1076. return $manager;
  1077. });
  1078. /** @deprecated 19.0.0 */
  1079. $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
  1080. $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
  1081. $this->registerService('ThemingDefaults', function (Server $c) {
  1082. try {
  1083. $classExists = class_exists('OCA\Theming\ThemingDefaults');
  1084. } catch (\OCP\AutoloadNotAllowedException $e) {
  1085. // App disabled or in maintenance mode
  1086. $classExists = false;
  1087. }
  1088. if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
  1089. $backgroundService = new BackgroundService(
  1090. $c->get(IRootFolder::class),
  1091. $c->getAppDataDir('theming'),
  1092. $c->get(\OCP\IConfig::class),
  1093. $c->get(ISession::class)->get('user_id'),
  1094. );
  1095. $imageManager = new ImageManager(
  1096. $c->get(\OCP\IConfig::class),
  1097. $c->getAppDataDir('theming'),
  1098. $c->get(IURLGenerator::class),
  1099. $c->get(ICacheFactory::class),
  1100. $c->get(LoggerInterface::class),
  1101. $c->get(ITempManager::class),
  1102. $backgroundService,
  1103. );
  1104. return new ThemingDefaults(
  1105. $c->get(\OCP\IConfig::class),
  1106. $c->getL10N('theming'),
  1107. $c->get(IUserSession::class),
  1108. $c->get(IURLGenerator::class),
  1109. $c->get(ICacheFactory::class),
  1110. new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
  1111. $imageManager,
  1112. $c->get(IAppManager::class),
  1113. $c->get(INavigationManager::class),
  1114. $backgroundService,
  1115. );
  1116. }
  1117. return new \OC_Defaults();
  1118. });
  1119. $this->registerService(JSCombiner::class, function (Server $c) {
  1120. return new JSCombiner(
  1121. $c->getAppDataDir('js'),
  1122. $c->get(IURLGenerator::class),
  1123. $this->get(ICacheFactory::class),
  1124. $c->get(SystemConfig::class),
  1125. $c->get(LoggerInterface::class)
  1126. );
  1127. });
  1128. $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
  1129. $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
  1130. // FIXME: Instantiated here due to cyclic dependency
  1131. $request = new Request(
  1132. [
  1133. 'get' => $_GET,
  1134. 'post' => $_POST,
  1135. 'files' => $_FILES,
  1136. 'server' => $_SERVER,
  1137. 'env' => $_ENV,
  1138. 'cookies' => $_COOKIE,
  1139. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  1140. ? $_SERVER['REQUEST_METHOD']
  1141. : null,
  1142. ],
  1143. $c->get(IRequestId::class),
  1144. $c->get(\OCP\IConfig::class)
  1145. );
  1146. return new CryptoWrapper(
  1147. $c->get(\OCP\IConfig::class),
  1148. $c->get(ICrypto::class),
  1149. $c->get(ISecureRandom::class),
  1150. $request
  1151. );
  1152. });
  1153. /** @deprecated 19.0.0 */
  1154. $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
  1155. $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
  1156. return new SessionStorage($c->get(ISession::class));
  1157. });
  1158. $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
  1159. /** @deprecated 19.0.0 */
  1160. $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
  1161. $this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
  1162. $config = $c->get(\OCP\IConfig::class);
  1163. $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
  1164. /** @var \OCP\Share\IProviderFactory $factory */
  1165. return new $factoryClass($this);
  1166. });
  1167. $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
  1168. /** @deprecated 19.0.0 */
  1169. $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
  1170. $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
  1171. $instance = new Collaboration\Collaborators\Search($c);
  1172. // register default plugins
  1173. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
  1174. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
  1175. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
  1176. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
  1177. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
  1178. return $instance;
  1179. });
  1180. /** @deprecated 19.0.0 */
  1181. $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
  1182. $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
  1183. $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
  1184. $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
  1185. $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
  1186. $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
  1187. $this->registerAlias(ITeamManager::class, TeamManager::class);
  1188. $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
  1189. $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
  1190. $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
  1191. return new \OC\Files\AppData\Factory(
  1192. $c->get(IRootFolder::class),
  1193. $c->get(SystemConfig::class)
  1194. );
  1195. });
  1196. $this->registerService('LockdownManager', function (ContainerInterface $c) {
  1197. return new LockdownManager(function () use ($c) {
  1198. return $c->get(ISession::class);
  1199. });
  1200. });
  1201. $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
  1202. return new DiscoveryService(
  1203. $c->get(ICacheFactory::class),
  1204. $c->get(IClientService::class)
  1205. );
  1206. });
  1207. $this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
  1208. $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
  1209. return new CloudIdManager(
  1210. $c->get(\OCP\Contacts\IManager::class),
  1211. $c->get(IURLGenerator::class),
  1212. $c->get(IUserManager::class),
  1213. $c->get(ICacheFactory::class),
  1214. $c->get(IEventDispatcher::class),
  1215. );
  1216. });
  1217. $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
  1218. $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
  1219. return new CloudFederationProviderManager(
  1220. $c->get(\OCP\IConfig::class),
  1221. $c->get(IAppManager::class),
  1222. $c->get(IClientService::class),
  1223. $c->get(ICloudIdManager::class),
  1224. $c->get(IOCMDiscoveryService::class),
  1225. $c->get(LoggerInterface::class)
  1226. );
  1227. });
  1228. $this->registerService(ICloudFederationFactory::class, function (Server $c) {
  1229. return new CloudFederationFactory();
  1230. });
  1231. $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
  1232. /** @deprecated 19.0.0 */
  1233. $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
  1234. $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
  1235. $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
  1236. /** @deprecated 19.0.0 */
  1237. $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
  1238. $this->registerService(Defaults::class, function (Server $c) {
  1239. return new Defaults(
  1240. $c->get('ThemingDefaults')
  1241. );
  1242. });
  1243. /** @deprecated 19.0.0 */
  1244. $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
  1245. $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
  1246. return $c->get(\OCP\IUserSession::class)->getSession();
  1247. }, false);
  1248. $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
  1249. return new ShareHelper(
  1250. $c->get(\OCP\Share\IManager::class)
  1251. );
  1252. });
  1253. $this->registerService(Installer::class, function (ContainerInterface $c) {
  1254. return new Installer(
  1255. $c->get(AppFetcher::class),
  1256. $c->get(IClientService::class),
  1257. $c->get(ITempManager::class),
  1258. $c->get(LoggerInterface::class),
  1259. $c->get(\OCP\IConfig::class),
  1260. \OC::$CLI
  1261. );
  1262. });
  1263. $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
  1264. return new ApiFactory($c->get(IClientService::class));
  1265. });
  1266. $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
  1267. $memcacheFactory = $c->get(ICacheFactory::class);
  1268. return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
  1269. });
  1270. $this->registerAlias(IContactsStore::class, ContactsStore::class);
  1271. $this->registerAlias(IAccountManager::class, AccountManager::class);
  1272. $this->registerAlias(IStorageFactory::class, StorageFactory::class);
  1273. $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
  1274. $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
  1275. $this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
  1276. $this->registerAlias(ISubAdmin::class, SubAdmin::class);
  1277. $this->registerAlias(IInitialStateService::class, InitialStateService::class);
  1278. $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
  1279. $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
  1280. $this->registerAlias(IBroker::class, Broker::class);
  1281. $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
  1282. $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
  1283. $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
  1284. $this->registerAlias(ITranslationManager::class, TranslationManager::class);
  1285. $this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
  1286. $this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
  1287. $this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
  1288. $this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
  1289. $this->registerAlias(ILimiter::class, Limiter::class);
  1290. $this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
  1291. $this->registerAlias(IOCMProvider::class, OCMProvider::class);
  1292. $this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
  1293. $this->registerAlias(IProfileManager::class, ProfileManager::class);
  1294. $this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
  1295. $this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
  1296. $this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
  1297. $this->connectDispatcher();
  1298. }
  1299. public function boot() {
  1300. /** @var HookConnector $hookConnector */
  1301. $hookConnector = $this->get(HookConnector::class);
  1302. $hookConnector->viewToNode();
  1303. }
  1304. /**
  1305. * @return \OCP\Calendar\IManager
  1306. * @deprecated 20.0.0
  1307. */
  1308. public function getCalendarManager() {
  1309. return $this->get(\OC\Calendar\Manager::class);
  1310. }
  1311. /**
  1312. * @return \OCP\Calendar\Resource\IManager
  1313. * @deprecated 20.0.0
  1314. */
  1315. public function getCalendarResourceBackendManager() {
  1316. return $this->get(\OC\Calendar\Resource\Manager::class);
  1317. }
  1318. /**
  1319. * @return \OCP\Calendar\Room\IManager
  1320. * @deprecated 20.0.0
  1321. */
  1322. public function getCalendarRoomBackendManager() {
  1323. return $this->get(\OC\Calendar\Room\Manager::class);
  1324. }
  1325. private function connectDispatcher(): void {
  1326. /** @var IEventDispatcher $eventDispatcher */
  1327. $eventDispatcher = $this->get(IEventDispatcher::class);
  1328. $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
  1329. $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
  1330. $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
  1331. $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
  1332. FilesMetadataManager::loadListeners($eventDispatcher);
  1333. GenerateBlurhashMetadata::loadListeners($eventDispatcher);
  1334. }
  1335. /**
  1336. * @return \OCP\Contacts\IManager
  1337. * @deprecated 20.0.0
  1338. */
  1339. public function getContactsManager() {
  1340. return $this->get(\OCP\Contacts\IManager::class);
  1341. }
  1342. /**
  1343. * @return \OC\Encryption\Manager
  1344. * @deprecated 20.0.0
  1345. */
  1346. public function getEncryptionManager() {
  1347. return $this->get(\OCP\Encryption\IManager::class);
  1348. }
  1349. /**
  1350. * @return \OC\Encryption\File
  1351. * @deprecated 20.0.0
  1352. */
  1353. public function getEncryptionFilesHelper() {
  1354. return $this->get(IFile::class);
  1355. }
  1356. /**
  1357. * @return \OCP\Encryption\Keys\IStorage
  1358. * @deprecated 20.0.0
  1359. */
  1360. public function getEncryptionKeyStorage() {
  1361. return $this->get(IStorage::class);
  1362. }
  1363. /**
  1364. * The current request object holding all information about the request
  1365. * currently being processed is returned from this method.
  1366. * In case the current execution was not initiated by a web request null is returned
  1367. *
  1368. * @return \OCP\IRequest
  1369. * @deprecated 20.0.0
  1370. */
  1371. public function getRequest() {
  1372. return $this->get(IRequest::class);
  1373. }
  1374. /**
  1375. * Returns the preview manager which can create preview images for a given file
  1376. *
  1377. * @return IPreview
  1378. * @deprecated 20.0.0
  1379. */
  1380. public function getPreviewManager() {
  1381. return $this->get(IPreview::class);
  1382. }
  1383. /**
  1384. * Returns the tag manager which can get and set tags for different object types
  1385. *
  1386. * @see \OCP\ITagManager::load()
  1387. * @return ITagManager
  1388. * @deprecated 20.0.0
  1389. */
  1390. public function getTagManager() {
  1391. return $this->get(ITagManager::class);
  1392. }
  1393. /**
  1394. * Returns the system-tag manager
  1395. *
  1396. * @return ISystemTagManager
  1397. *
  1398. * @since 9.0.0
  1399. * @deprecated 20.0.0
  1400. */
  1401. public function getSystemTagManager() {
  1402. return $this->get(ISystemTagManager::class);
  1403. }
  1404. /**
  1405. * Returns the system-tag object mapper
  1406. *
  1407. * @return ISystemTagObjectMapper
  1408. *
  1409. * @since 9.0.0
  1410. * @deprecated 20.0.0
  1411. */
  1412. public function getSystemTagObjectMapper() {
  1413. return $this->get(ISystemTagObjectMapper::class);
  1414. }
  1415. /**
  1416. * Returns the avatar manager, used for avatar functionality
  1417. *
  1418. * @return IAvatarManager
  1419. * @deprecated 20.0.0
  1420. */
  1421. public function getAvatarManager() {
  1422. return $this->get(IAvatarManager::class);
  1423. }
  1424. /**
  1425. * Returns the root folder of ownCloud's data directory
  1426. *
  1427. * @return IRootFolder
  1428. * @deprecated 20.0.0
  1429. */
  1430. public function getRootFolder() {
  1431. return $this->get(IRootFolder::class);
  1432. }
  1433. /**
  1434. * Returns the root folder of ownCloud's data directory
  1435. * This is the lazy variant so this gets only initialized once it
  1436. * is actually used.
  1437. *
  1438. * @return IRootFolder
  1439. * @deprecated 20.0.0
  1440. */
  1441. public function getLazyRootFolder() {
  1442. return $this->get(IRootFolder::class);
  1443. }
  1444. /**
  1445. * Returns a view to ownCloud's files folder
  1446. *
  1447. * @param string $userId user ID
  1448. * @return \OCP\Files\Folder|null
  1449. * @deprecated 20.0.0
  1450. */
  1451. public function getUserFolder($userId = null) {
  1452. if ($userId === null) {
  1453. $user = $this->get(IUserSession::class)->getUser();
  1454. if (!$user) {
  1455. return null;
  1456. }
  1457. $userId = $user->getUID();
  1458. }
  1459. $root = $this->get(IRootFolder::class);
  1460. return $root->getUserFolder($userId);
  1461. }
  1462. /**
  1463. * @return \OC\User\Manager
  1464. * @deprecated 20.0.0
  1465. */
  1466. public function getUserManager() {
  1467. return $this->get(IUserManager::class);
  1468. }
  1469. /**
  1470. * @return \OC\Group\Manager
  1471. * @deprecated 20.0.0
  1472. */
  1473. public function getGroupManager() {
  1474. return $this->get(IGroupManager::class);
  1475. }
  1476. /**
  1477. * @return \OC\User\Session
  1478. * @deprecated 20.0.0
  1479. */
  1480. public function getUserSession() {
  1481. return $this->get(IUserSession::class);
  1482. }
  1483. /**
  1484. * @return \OCP\ISession
  1485. * @deprecated 20.0.0
  1486. */
  1487. public function getSession() {
  1488. return $this->get(Session::class)->getSession();
  1489. }
  1490. /**
  1491. * @param \OCP\ISession $session
  1492. * @return void
  1493. */
  1494. public function setSession(\OCP\ISession $session) {
  1495. $this->get(SessionStorage::class)->setSession($session);
  1496. $this->get(Session::class)->setSession($session);
  1497. $this->get(Store::class)->setSession($session);
  1498. }
  1499. /**
  1500. * @return \OC\Authentication\TwoFactorAuth\Manager
  1501. * @deprecated 20.0.0
  1502. */
  1503. public function getTwoFactorAuthManager() {
  1504. return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
  1505. }
  1506. /**
  1507. * @return \OC\NavigationManager
  1508. * @deprecated 20.0.0
  1509. */
  1510. public function getNavigationManager() {
  1511. return $this->get(INavigationManager::class);
  1512. }
  1513. /**
  1514. * @return \OCP\IConfig
  1515. * @deprecated 20.0.0
  1516. */
  1517. public function getConfig() {
  1518. return $this->get(AllConfig::class);
  1519. }
  1520. /**
  1521. * @return \OC\SystemConfig
  1522. * @deprecated 20.0.0
  1523. */
  1524. public function getSystemConfig() {
  1525. return $this->get(SystemConfig::class);
  1526. }
  1527. /**
  1528. * Returns the app config manager
  1529. *
  1530. * @return IAppConfig
  1531. * @deprecated 20.0.0
  1532. */
  1533. public function getAppConfig() {
  1534. return $this->get(IAppConfig::class);
  1535. }
  1536. /**
  1537. * @return IFactory
  1538. * @deprecated 20.0.0
  1539. */
  1540. public function getL10NFactory() {
  1541. return $this->get(IFactory::class);
  1542. }
  1543. /**
  1544. * get an L10N instance
  1545. *
  1546. * @param string $app appid
  1547. * @param string $lang
  1548. * @return IL10N
  1549. * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
  1550. */
  1551. public function getL10N($app, $lang = null) {
  1552. return $this->get(IFactory::class)->get($app, $lang);
  1553. }
  1554. /**
  1555. * @return IURLGenerator
  1556. * @deprecated 20.0.0
  1557. */
  1558. public function getURLGenerator() {
  1559. return $this->get(IURLGenerator::class);
  1560. }
  1561. /**
  1562. * @return AppFetcher
  1563. * @deprecated 20.0.0
  1564. */
  1565. public function getAppFetcher() {
  1566. return $this->get(AppFetcher::class);
  1567. }
  1568. /**
  1569. * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
  1570. * getMemCacheFactory() instead.
  1571. *
  1572. * @return ICache
  1573. * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
  1574. */
  1575. public function getCache() {
  1576. return $this->get(ICache::class);
  1577. }
  1578. /**
  1579. * Returns an \OCP\CacheFactory instance
  1580. *
  1581. * @return \OCP\ICacheFactory
  1582. * @deprecated 20.0.0
  1583. */
  1584. public function getMemCacheFactory() {
  1585. return $this->get(ICacheFactory::class);
  1586. }
  1587. /**
  1588. * Returns an \OC\RedisFactory instance
  1589. *
  1590. * @return \OC\RedisFactory
  1591. * @deprecated 20.0.0
  1592. */
  1593. public function getGetRedisFactory() {
  1594. return $this->get('RedisFactory');
  1595. }
  1596. /**
  1597. * Returns the current session
  1598. *
  1599. * @return \OCP\IDBConnection
  1600. * @deprecated 20.0.0
  1601. */
  1602. public function getDatabaseConnection() {
  1603. return $this->get(IDBConnection::class);
  1604. }
  1605. /**
  1606. * Returns the activity manager
  1607. *
  1608. * @return \OCP\Activity\IManager
  1609. * @deprecated 20.0.0
  1610. */
  1611. public function getActivityManager() {
  1612. return $this->get(\OCP\Activity\IManager::class);
  1613. }
  1614. /**
  1615. * Returns an job list for controlling background jobs
  1616. *
  1617. * @return IJobList
  1618. * @deprecated 20.0.0
  1619. */
  1620. public function getJobList() {
  1621. return $this->get(IJobList::class);
  1622. }
  1623. /**
  1624. * Returns a logger instance
  1625. *
  1626. * @return ILogger
  1627. * @deprecated 20.0.0
  1628. */
  1629. public function getLogger() {
  1630. return $this->get(ILogger::class);
  1631. }
  1632. /**
  1633. * @return ILogFactory
  1634. * @throws \OCP\AppFramework\QueryException
  1635. * @deprecated 20.0.0
  1636. */
  1637. public function getLogFactory() {
  1638. return $this->get(ILogFactory::class);
  1639. }
  1640. /**
  1641. * Returns a router for generating and matching urls
  1642. *
  1643. * @return IRouter
  1644. * @deprecated 20.0.0
  1645. */
  1646. public function getRouter() {
  1647. return $this->get(IRouter::class);
  1648. }
  1649. /**
  1650. * Returns a search instance
  1651. *
  1652. * @return ISearch
  1653. * @deprecated 20.0.0
  1654. */
  1655. public function getSearch() {
  1656. return $this->get(ISearch::class);
  1657. }
  1658. /**
  1659. * Returns a SecureRandom instance
  1660. *
  1661. * @return \OCP\Security\ISecureRandom
  1662. * @deprecated 20.0.0
  1663. */
  1664. public function getSecureRandom() {
  1665. return $this->get(ISecureRandom::class);
  1666. }
  1667. /**
  1668. * Returns a Crypto instance
  1669. *
  1670. * @return ICrypto
  1671. * @deprecated 20.0.0
  1672. */
  1673. public function getCrypto() {
  1674. return $this->get(ICrypto::class);
  1675. }
  1676. /**
  1677. * Returns a Hasher instance
  1678. *
  1679. * @return IHasher
  1680. * @deprecated 20.0.0
  1681. */
  1682. public function getHasher() {
  1683. return $this->get(IHasher::class);
  1684. }
  1685. /**
  1686. * Returns a CredentialsManager instance
  1687. *
  1688. * @return ICredentialsManager
  1689. * @deprecated 20.0.0
  1690. */
  1691. public function getCredentialsManager() {
  1692. return $this->get(ICredentialsManager::class);
  1693. }
  1694. /**
  1695. * Get the certificate manager
  1696. *
  1697. * @return \OCP\ICertificateManager
  1698. */
  1699. public function getCertificateManager() {
  1700. return $this->get(ICertificateManager::class);
  1701. }
  1702. /**
  1703. * Returns an instance of the HTTP client service
  1704. *
  1705. * @return IClientService
  1706. * @deprecated 20.0.0
  1707. */
  1708. public function getHTTPClientService() {
  1709. return $this->get(IClientService::class);
  1710. }
  1711. /**
  1712. * Get the active event logger
  1713. *
  1714. * The returned logger only logs data when debug mode is enabled
  1715. *
  1716. * @return IEventLogger
  1717. * @deprecated 20.0.0
  1718. */
  1719. public function getEventLogger() {
  1720. return $this->get(IEventLogger::class);
  1721. }
  1722. /**
  1723. * Get the active query logger
  1724. *
  1725. * The returned logger only logs data when debug mode is enabled
  1726. *
  1727. * @return IQueryLogger
  1728. * @deprecated 20.0.0
  1729. */
  1730. public function getQueryLogger() {
  1731. return $this->get(IQueryLogger::class);
  1732. }
  1733. /**
  1734. * Get the manager for temporary files and folders
  1735. *
  1736. * @return \OCP\ITempManager
  1737. * @deprecated 20.0.0
  1738. */
  1739. public function getTempManager() {
  1740. return $this->get(ITempManager::class);
  1741. }
  1742. /**
  1743. * Get the app manager
  1744. *
  1745. * @return \OCP\App\IAppManager
  1746. * @deprecated 20.0.0
  1747. */
  1748. public function getAppManager() {
  1749. return $this->get(IAppManager::class);
  1750. }
  1751. /**
  1752. * Creates a new mailer
  1753. *
  1754. * @return IMailer
  1755. * @deprecated 20.0.0
  1756. */
  1757. public function getMailer() {
  1758. return $this->get(IMailer::class);
  1759. }
  1760. /**
  1761. * Get the webroot
  1762. *
  1763. * @return string
  1764. * @deprecated 20.0.0
  1765. */
  1766. public function getWebRoot() {
  1767. return $this->webRoot;
  1768. }
  1769. /**
  1770. * @return \OC\OCSClient
  1771. * @deprecated 20.0.0
  1772. */
  1773. public function getOcsClient() {
  1774. return $this->get('OcsClient');
  1775. }
  1776. /**
  1777. * @return IDateTimeZone
  1778. * @deprecated 20.0.0
  1779. */
  1780. public function getDateTimeZone() {
  1781. return $this->get(IDateTimeZone::class);
  1782. }
  1783. /**
  1784. * @return IDateTimeFormatter
  1785. * @deprecated 20.0.0
  1786. */
  1787. public function getDateTimeFormatter() {
  1788. return $this->get(IDateTimeFormatter::class);
  1789. }
  1790. /**
  1791. * @return IMountProviderCollection
  1792. * @deprecated 20.0.0
  1793. */
  1794. public function getMountProviderCollection() {
  1795. return $this->get(IMountProviderCollection::class);
  1796. }
  1797. /**
  1798. * Get the IniWrapper
  1799. *
  1800. * @return IniGetWrapper
  1801. * @deprecated 20.0.0
  1802. */
  1803. public function getIniWrapper() {
  1804. return $this->get(IniGetWrapper::class);
  1805. }
  1806. /**
  1807. * @return \OCP\Command\IBus
  1808. * @deprecated 20.0.0
  1809. */
  1810. public function getCommandBus() {
  1811. return $this->get(IBus::class);
  1812. }
  1813. /**
  1814. * Get the trusted domain helper
  1815. *
  1816. * @return TrustedDomainHelper
  1817. * @deprecated 20.0.0
  1818. */
  1819. public function getTrustedDomainHelper() {
  1820. return $this->get(TrustedDomainHelper::class);
  1821. }
  1822. /**
  1823. * Get the locking provider
  1824. *
  1825. * @return ILockingProvider
  1826. * @since 8.1.0
  1827. * @deprecated 20.0.0
  1828. */
  1829. public function getLockingProvider() {
  1830. return $this->get(ILockingProvider::class);
  1831. }
  1832. /**
  1833. * @return IMountManager
  1834. * @deprecated 20.0.0
  1835. **/
  1836. public function getMountManager() {
  1837. return $this->get(IMountManager::class);
  1838. }
  1839. /**
  1840. * @return IUserMountCache
  1841. * @deprecated 20.0.0
  1842. */
  1843. public function getUserMountCache() {
  1844. return $this->get(IUserMountCache::class);
  1845. }
  1846. /**
  1847. * Get the MimeTypeDetector
  1848. *
  1849. * @return IMimeTypeDetector
  1850. * @deprecated 20.0.0
  1851. */
  1852. public function getMimeTypeDetector() {
  1853. return $this->get(IMimeTypeDetector::class);
  1854. }
  1855. /**
  1856. * Get the MimeTypeLoader
  1857. *
  1858. * @return IMimeTypeLoader
  1859. * @deprecated 20.0.0
  1860. */
  1861. public function getMimeTypeLoader() {
  1862. return $this->get(IMimeTypeLoader::class);
  1863. }
  1864. /**
  1865. * Get the manager of all the capabilities
  1866. *
  1867. * @return CapabilitiesManager
  1868. * @deprecated 20.0.0
  1869. */
  1870. public function getCapabilitiesManager() {
  1871. return $this->get(CapabilitiesManager::class);
  1872. }
  1873. /**
  1874. * Get the Notification Manager
  1875. *
  1876. * @return \OCP\Notification\IManager
  1877. * @since 8.2.0
  1878. * @deprecated 20.0.0
  1879. */
  1880. public function getNotificationManager() {
  1881. return $this->get(\OCP\Notification\IManager::class);
  1882. }
  1883. /**
  1884. * @return ICommentsManager
  1885. * @deprecated 20.0.0
  1886. */
  1887. public function getCommentsManager() {
  1888. return $this->get(ICommentsManager::class);
  1889. }
  1890. /**
  1891. * @return \OCA\Theming\ThemingDefaults
  1892. * @deprecated 20.0.0
  1893. */
  1894. public function getThemingDefaults() {
  1895. return $this->get('ThemingDefaults');
  1896. }
  1897. /**
  1898. * @return \OC\IntegrityCheck\Checker
  1899. * @deprecated 20.0.0
  1900. */
  1901. public function getIntegrityCodeChecker() {
  1902. return $this->get('IntegrityCodeChecker');
  1903. }
  1904. /**
  1905. * @return \OC\Session\CryptoWrapper
  1906. * @deprecated 20.0.0
  1907. */
  1908. public function getSessionCryptoWrapper() {
  1909. return $this->get('CryptoWrapper');
  1910. }
  1911. /**
  1912. * @return CsrfTokenManager
  1913. * @deprecated 20.0.0
  1914. */
  1915. public function getCsrfTokenManager() {
  1916. return $this->get(CsrfTokenManager::class);
  1917. }
  1918. /**
  1919. * @return IThrottler
  1920. * @deprecated 20.0.0
  1921. */
  1922. public function getBruteForceThrottler() {
  1923. return $this->get(Throttler::class);
  1924. }
  1925. /**
  1926. * @return IContentSecurityPolicyManager
  1927. * @deprecated 20.0.0
  1928. */
  1929. public function getContentSecurityPolicyManager() {
  1930. return $this->get(ContentSecurityPolicyManager::class);
  1931. }
  1932. /**
  1933. * @return ContentSecurityPolicyNonceManager
  1934. * @deprecated 20.0.0
  1935. */
  1936. public function getContentSecurityPolicyNonceManager() {
  1937. return $this->get(ContentSecurityPolicyNonceManager::class);
  1938. }
  1939. /**
  1940. * Not a public API as of 8.2, wait for 9.0
  1941. *
  1942. * @return \OCA\Files_External\Service\BackendService
  1943. * @deprecated 20.0.0
  1944. */
  1945. public function getStoragesBackendService() {
  1946. return $this->get(BackendService::class);
  1947. }
  1948. /**
  1949. * Not a public API as of 8.2, wait for 9.0
  1950. *
  1951. * @return \OCA\Files_External\Service\GlobalStoragesService
  1952. * @deprecated 20.0.0
  1953. */
  1954. public function getGlobalStoragesService() {
  1955. return $this->get(GlobalStoragesService::class);
  1956. }
  1957. /**
  1958. * Not a public API as of 8.2, wait for 9.0
  1959. *
  1960. * @return \OCA\Files_External\Service\UserGlobalStoragesService
  1961. * @deprecated 20.0.0
  1962. */
  1963. public function getUserGlobalStoragesService() {
  1964. return $this->get(UserGlobalStoragesService::class);
  1965. }
  1966. /**
  1967. * Not a public API as of 8.2, wait for 9.0
  1968. *
  1969. * @return \OCA\Files_External\Service\UserStoragesService
  1970. * @deprecated 20.0.0
  1971. */
  1972. public function getUserStoragesService() {
  1973. return $this->get(UserStoragesService::class);
  1974. }
  1975. /**
  1976. * @return \OCP\Share\IManager
  1977. * @deprecated 20.0.0
  1978. */
  1979. public function getShareManager() {
  1980. return $this->get(\OCP\Share\IManager::class);
  1981. }
  1982. /**
  1983. * @return \OCP\Collaboration\Collaborators\ISearch
  1984. * @deprecated 20.0.0
  1985. */
  1986. public function getCollaboratorSearch() {
  1987. return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
  1988. }
  1989. /**
  1990. * @return \OCP\Collaboration\AutoComplete\IManager
  1991. * @deprecated 20.0.0
  1992. */
  1993. public function getAutoCompleteManager() {
  1994. return $this->get(IManager::class);
  1995. }
  1996. /**
  1997. * Returns the LDAP Provider
  1998. *
  1999. * @return \OCP\LDAP\ILDAPProvider
  2000. * @deprecated 20.0.0
  2001. */
  2002. public function getLDAPProvider() {
  2003. return $this->get('LDAPProvider');
  2004. }
  2005. /**
  2006. * @return \OCP\Settings\IManager
  2007. * @deprecated 20.0.0
  2008. */
  2009. public function getSettingsManager() {
  2010. return $this->get(\OC\Settings\Manager::class);
  2011. }
  2012. /**
  2013. * @return \OCP\Files\IAppData
  2014. * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
  2015. */
  2016. public function getAppDataDir($app) {
  2017. /** @var \OC\Files\AppData\Factory $factory */
  2018. $factory = $this->get(\OC\Files\AppData\Factory::class);
  2019. return $factory->get($app);
  2020. }
  2021. /**
  2022. * @return \OCP\Lockdown\ILockdownManager
  2023. * @deprecated 20.0.0
  2024. */
  2025. public function getLockdownManager() {
  2026. return $this->get('LockdownManager');
  2027. }
  2028. /**
  2029. * @return \OCP\Federation\ICloudIdManager
  2030. * @deprecated 20.0.0
  2031. */
  2032. public function getCloudIdManager() {
  2033. return $this->get(ICloudIdManager::class);
  2034. }
  2035. /**
  2036. * @return \OCP\GlobalScale\IConfig
  2037. * @deprecated 20.0.0
  2038. */
  2039. public function getGlobalScaleConfig() {
  2040. return $this->get(IConfig::class);
  2041. }
  2042. /**
  2043. * @return \OCP\Federation\ICloudFederationProviderManager
  2044. * @deprecated 20.0.0
  2045. */
  2046. public function getCloudFederationProviderManager() {
  2047. return $this->get(ICloudFederationProviderManager::class);
  2048. }
  2049. /**
  2050. * @return \OCP\Remote\Api\IApiFactory
  2051. * @deprecated 20.0.0
  2052. */
  2053. public function getRemoteApiFactory() {
  2054. return $this->get(IApiFactory::class);
  2055. }
  2056. /**
  2057. * @return \OCP\Federation\ICloudFederationFactory
  2058. * @deprecated 20.0.0
  2059. */
  2060. public function getCloudFederationFactory() {
  2061. return $this->get(ICloudFederationFactory::class);
  2062. }
  2063. /**
  2064. * @return \OCP\Remote\IInstanceFactory
  2065. * @deprecated 20.0.0
  2066. */
  2067. public function getRemoteInstanceFactory() {
  2068. return $this->get(IInstanceFactory::class);
  2069. }
  2070. /**
  2071. * @return IStorageFactory
  2072. * @deprecated 20.0.0
  2073. */
  2074. public function getStorageFactory() {
  2075. return $this->get(IStorageFactory::class);
  2076. }
  2077. /**
  2078. * Get the Preview GeneratorHelper
  2079. *
  2080. * @return GeneratorHelper
  2081. * @since 17.0.0
  2082. * @deprecated 20.0.0
  2083. */
  2084. public function getGeneratorHelper() {
  2085. return $this->get(\OC\Preview\GeneratorHelper::class);
  2086. }
  2087. private function registerDeprecatedAlias(string $alias, string $target) {
  2088. $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
  2089. try {
  2090. /** @var LoggerInterface $logger */
  2091. $logger = $container->get(LoggerInterface::class);
  2092. $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
  2093. } catch (ContainerExceptionInterface $e) {
  2094. // Could not get logger. Continue
  2095. }
  2096. return $container->get($target);
  2097. }, false);
  2098. }
  2099. }