Server.php 73 KB

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