Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Server.php 72KB

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