Server.php 71 KB

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