Server.php 72 KB

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