1
0

Server.php 71 KB

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