1
0

Server.php 73 KB

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