Server.php 72 KB

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