Server.php 72 KB

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