Server.php 73 KB

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