Server.php 72 KB

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