Server.php 72 KB

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