Server.php 72 KB

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