1
0

Server.php 73 KB

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